Quality Control & Assurance Flashcards
7 cards from real Excel VBA practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Quality Control & Assurance flashcards as text
A QA macro must report rows where the value in column C does not match the pattern 'AA-####' (two letters, hyphen, four digits). Which VBA tool handles this?
Answer: cell.Value Like '[A-Z][A-Z]-####'
The Like operator with the pattern '[A-Z][A-Z]-####' matches exactly two uppercase letters, a hyphen, and four digits.
Which method should a QA macro use to programmatically add a data validation rule to a cell that restricts input to whole numbers between 1 and 100?
Answer: cell.Validation.Add Type:=xlValidateWholeNumber, Minimum:='1', Maximum:='100'
The Validation.Add method on a Range object with xlValidateWholeNumber type configures whole-number input restrictions.
A QA log workbook must record timestamps for each error found. Which VBA expression returns the current date and time as a single value?
Answer: Now()
Now() is the VBA built-in function that returns the current date and time combined as a Date value.
To ensure a QA macro handles both 32-bit and 64-bit Excel environments when declaring Windows API functions, which compiler directive is used?
Answer: #If VBA7 Then ... #Else ... #End If
The #If VBA7 compiler directive checks for VBA version 7 (Excel 2010+, 64-bit capable) and is the correct conditional for PtrSafe declarations.
Which technique allows a VBA QA macro to test a Private Sub in a standard module without changing its access modifier?
Answer: Use Application.Run 'ModuleName.SubName' from another module
Application.Run accepts a string with the module and procedure name, allowing external callers to invoke Private procedures by name.
A QA macro compares two ranges and must collect all differing cell addresses into a single Range object. Which method combines individual cell references?
Answer: Application.Union
Application.Union combines two or more Range objects into one, allowing you to collect mismatched cells for bulk formatting or reporting.
When writing a VBA unit test for a function that calculates a discount, which practice improves test reliability?
Answer: Use hardcoded input/expected-output pairs that cover boundary values like 0%, 100%, and edge percentages
Hardcoded boundary-value test cases (zero, maximum, and edge inputs) catch off-by-one errors and logic faults independently of live data.