0
0
Excelspreadsheet~10 mins

Simple VBA procedures in Excel - Real Business Scenario

Choose your learning style9 modes available
Scenario Mode
👤 Your Role: You are an office assistant learning to automate tasks in Excel.
📋 Request: Your manager wants you to create a simple VBA procedure that clears the contents of a specific range and then fills it with a welcome message.
📊 Data: You have a worksheet with some text and numbers in cells A1 to A5.
🎯 Deliverable: A VBA procedure that clears cells A1 to A5 and writes 'Welcome!' in cell A1.
Progress0 / 5 steps
Sample Data
A
Old Data 1
Old Data 2
Old Data 3
Old Data 4
Old Data 5
1
Step 1: Open the Excel workbook and press Alt + F11 to open the VBA editor.
Expected Result
VBA editor window opens.
2
Step 2: In the VBA editor, insert a new module by clicking Insert > Module.
Expected Result
A new blank module appears for code entry.
3
Step 3: Write a VBA procedure named ClearAndWelcome that clears cells A1 to A5 and writes 'Welcome!' in cell A1.
Sub ClearAndWelcome() Range("A1:A5").ClearContents Range("A1").Value = "Welcome!" End Sub
Expected Result
Procedure code is entered without errors.
4
Step 4: Close the VBA editor and return to the Excel worksheet.
Expected Result
Back to Excel sheet with original data visible.
5
Step 5: Run the ClearAndWelcome procedure by pressing Alt + F8, selecting ClearAndWelcome, and clicking Run.
Expected Result
Cells A1 to A5 are cleared and cell A1 shows 'Welcome!'.
Final Result
A
Welcome!



The VBA procedure successfully clears the specified range.
The welcome message appears in the first cell after running the macro.
This simple automation saves time by replacing manual clearing and typing.
Bonus Challenge

Modify the VBA procedure to also change the font color of the welcome message to blue.

Show Hint
Use Range("A1").Font.Color = RGB(0, 0, 255) inside the procedure.