Excel VBA Communication & Stakeholder Relations 5 — Questions and Answers
Question 1: A department head wants to review macro changes before they go live. Which VBA IDE feature lets you step through code one line at a time to demonstrate logic to a stakeholder?
- F8 (Step Into) in the VBA IDE (Correct answer)
- Ctrl+F5 (Run to Cursor)
- F5 (Run Sub)
- Ctrl+Break then F8
Correct answer: F8 (Step Into) in the VBA IDE
Pressing F8 in the VBA IDE steps through code one line at a time, allowing you to demonstrate execution flow interactively.
Question 2: Your macro must send different email bodies depending on whether a KPI is met. Which VBA structure best models this conditional communication logic?
- If...Then...Else block assigning different body text (Correct answer)
- Select Case on the email recipient
- For Each loop over all cells
- Do While loop checking the KPI
Correct answer: If...Then...Else block assigning different body text
An If...Then...Else block evaluates the KPI condition and branches to assign the appropriate message body string.
Question 3: Stakeholders need a macro that inserts a formatted table of results into an email body as HTML. Which MailItem property accepts HTML content?
- .HTMLBody (Correct answer)
- .Body
- .RichText
- .HTMLContent
Correct answer: .HTMLBody
The .HTMLBody property of an Outlook MailItem accepts an HTML string, enabling formatted tables, colors, and links in the email.
Question 4: A compliance officer wants every macro run logged with the username and timestamp. Which VBA function returns the current Windows username?
- Environ("USERNAME") (Correct answer)
- Application.UserName
- System.User.Name
- GetUserName()
Correct answer: Environ("USERNAME")
Environ("USERNAME") reads the Windows environment variable USERNAME, which always reflects the logged-in OS user.
Question 5: Your macro needs to notify stakeholders only if data in a specific range has changed. Which Excel VBA event fires whenever a cell value changes on a worksheet?
- Worksheet_Change(ByVal Target As Range) (Correct answer)
- Worksheet_Update(ByVal Cell As Range)
- Workbook_DataChange(ByVal Range As Range)
- Application_CellChanged(ByVal Target As Range)
Correct answer: Worksheet_Change(ByVal Target As Range)
The Worksheet_Change event fires whenever a cell value is modified, and the Target parameter identifies which cell(s) changed.
Question 6: A stakeholder asks you to protect a sheet so users can only edit specific input cells, not the macro-generated output areas. Which VBA method applies sheet protection?
- ActiveSheet.Protect Password:="pass", UserInterfaceOnly:=True (Correct answer)
- ActiveSheet.Lock "pass"
- Worksheets.Protect Range("A1:Z100")
- ActiveSheet.EnableProtection = True
Correct answer: ActiveSheet.Protect Password:="pass", UserInterfaceOnly:=True
ActiveSheet.Protect with UserInterfaceOnly:=True locks the sheet from manual edits while still allowing VBA code to write to protected cells.
Question 7: After sending a report, a stakeholder replies asking why certain numbers differ from last week. To support auditability, your macro should save a version of the workbook with today's date in the filename. Which line constructs a dated filename?
- fileName = "Report_" & Format(Date, "YYYY-MM-DD") & ".xlsx" (Correct answer)
- fileName = "Report_" & Now() & ".xlsx"
- fileName = "Report_" & DateSerial(Year,Month,Day) & ".xlsx"
- fileName = "Report_" & CStr(Date) & ".xlsx"
Correct answer: fileName = "Report_" & Format(Date, "YYYY-MM-DD") & ".xlsx"
Format(Date, "YYYY-MM-DD") produces a sortable ISO date string that is safe for filenames, unlike raw Now() which includes colons.
A department head wants to review macro changes before they go live.
Which VBA IDE feature lets you step through code one line at a time to demonstrate logic to a stakeholder?