Which VBA statement is used to automate the opening of a workbook?
a) OpenWorkbook
b) Workbooks.Open
c) Workbook.Open
d) File.Open
Answer: b) Workbooks.Open
How do you automatically run a VBA macro when a workbook is opened?
a) Place the macro in the ThisWorkbook module under Workbook_Open event
b) Use the AutoRun event
c) Add the macro to the Quick Access Toolbar
d) Assign a shortcut key to the macro
Answer: a) Place the macro in the ThisWorkbook module under Workbook_Open event
Which VBA method would you use to automatically save a workbook?
a) Workbook.Save
b) Workbooks.Save
c) SaveWorkbook
d) File.Save
Answer: a) Workbook.Save
What VBA code would you use to copy a range of cells from one sheet to another?
a) Sheets("Sheet1").Range("A1:B10").Copy Destination:=Sheets("Sheet2").Range("A1")
b) Sheets("Sheet1").Range("A1:B10").CopyTo Sheets("Sheet2").Range("A1")
c) Sheets("Sheet1").Range("A1:B10").Paste Destination:=Sheets("Sheet2").Range("A1")
d) Sheets("Sheet1").Range("A1:B10").Transfer To Sheets("Sheet2").Range("A1")
Answer: a) Sheets("Sheet1").Range("A1:B10").Copy Destination:=Sheets("Sheet2").Range("A1")
Which VBA function is used to display a user form?
a) ShowForm
b) DisplayForm
c) UserForm.Show
d) Form.Show
Answer: c) UserForm.Show
How do you automatically format a range of cells in VBA?
a) Use the .Format method
b) Use the .Style method
c) Use the .Interior property
d) Use the .Cells property
Answer: c) Use the .Interior property
Which VBA method allows you to loop through all the worksheets in a workbook?
a) For Each ws In Worksheets
b) For ws In Sheets
c) Loop ws In Workbook
d) For ws In Workbooks
Answer: a) For Each ws In Worksheets
How do you use VBA to delete a worksheet?
a) Sheets("SheetName").Delete
b) Worksheets("SheetName").Remove
c) Sheets("SheetName").Remove
d) Sheets("SheetName").Clear
Answer: a) Sheets("SheetName").Delete
Which VBA event triggers when a cell value is changed?
a) Worksheet_Change
b) Worksheet_Activate
c) Workbook_Open
d) Workbook_SheetChange
Answer: a) Worksheet_Change
How can you create a new worksheet and rename it using VBA?
a) Sheets.Add.Name = "NewSheet"
b) Worksheets.Add.Name = "NewSheet"
c) Sheets.Add(After:=Sheets(Sheets.Count)).Name = "NewSheet"
d) Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "NewSheet"
Answer: c) Sheets.Add(After:=Sheets(Sheets.Count)).Name = "NewSheet"