- Access exercises (91)
- C# exercises (79)
- Excel exercises (278)
- Power Apps exercises (13)
- Power Automate exercises (18)
- Power BI exercises (139)
- Power Platform exercises (157)
- Python exercises (28)
- Report Builder exercises (141)
- SQL exercises (198)
- SSAS exercises (51)
- SSIS exercises (46)
- SSRS exercises (99)
- VBA exercises (85)
- Visual Basic exercises (46)
EXCEL VBA MACROS EXERCISES▼
Excel VBA Macros | Referencing other applications exercise | Using FileSystemObjects to manipulate files
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
The folder shown above contains a number of files, some of which are Excel workbooks.
Create a macro to loop over all of the files in the folder. Your macro should:
- Check for each file whether it is an Excel workbook (ie use the RIGHT function to check whether the right-most 3 or 4 characters of the file name are XLS or XLSX, depending on your Excel version)
- Open up the workbook with the given path
- Write your name into cell B2
- Close the workbook back down, saving any changes
If you can't remember how to open and close workbooks - record a macro!
When you have got the macro to work, save it as Signing workbooks, then close it down.
If you want another challenge, given the files in the folder above, create a macro in a new workbook which:
- Creates a new folder on your C drive with a name of your choice, if it doesn't already exist
- Copies all of the TXT files shown above into this folder
- Deletes the file called Po.txt
- Renames Laa Laa.txt to Yellow teletubbie.txt
Save this workbook as Various file tasks, then close it down.