Advanced Formula and Macro Creation Flashcards
6 cards from real Microsoft Excel practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Advanced Formula and Macro Creation flashcards as text
A user wants to create a formula that first calculates the total sales (Price * Quantity) and then applies a discount if the total is over $1,000. To avoid calculating the total sales twice within an IF statement, which function is most efficient for defining the total sales as a named variable within the formula?
Answer: LET
The LET function is designed to declare and assign values to variables within a formula's scope. This improves readability and performance by preventing redundant calculations. The user can define 'TotalSales' as Price * Quantity once and then reference 'TotalSales' in the subsequent calculation.
In a VBA macro, you need to iterate through each cell in a selected range and change the font color to red if the cell's value is negative. Which of the following loop structures is most suitable for this task?
Answer: For Each...Next
The 'For Each...Next' loop is specifically designed to iterate through each object in a collection, such as each cell in a range. This makes the code cleaner and more direct for this scenario compared to a 'For...Next' loop that would require a counter, or 'Do' loops which are better for conditions not tied to a fixed collection.
You are using the XLOOKUP function to find an employee's salary in a table. The formula is `=XLOOKUP(E2, A2:A100, D2:D100, "Not Found", 0, -1)`. What does the final argument, `-1`, specify?
Answer: The search will start from the bottom of the lookup array and go up.
The sixth argument in the XLOOKUP function is `[search_mode]`. A value of -1 specifies that the search should be conducted in reverse order, from the last item to the first. The default is 1, which searches from first to last.
A user enters the formula `=FILTER(A2:D50, C2:C50>100)` into cell F2. The result of this formula automatically populates cells F2 through I10. This behavior is known as:
Answer: Spilling
Spilling is the behavior in modern Excel where a formula that produces multiple results automatically populates, or 'spills', into adjacent cells. Dynamic array functions like FILTER, SORT, and UNIQUE exhibit this behavior.
Which of the following is a primary benefit of using the macro recorder to create a VBA macro?
Answer: It provides a quick way to generate VBA code for actions performed in the Excel interface, which can be a good starting point for customization.
The macro recorder translates user actions directly into VBA code. While this code is often not the most efficient, it serves as an excellent foundation. A user can record a series of actions and then edit the generated code to add loops, logic, or to clean it up, making it a valuable learning and development tool.
You need to write a VBA `Do While` loop that continues to execute as long as the value in cell A1 is less than 10. The code inside the loop increments the value of cell A1. What is a potential risk with the loop `Do While Range("A1").Value < 10`?
Answer: If the initial value of A1 is 10 or greater, the code inside the loop will never execute.
A `Do While` loop checks the condition at the very beginning. If the condition is false initially (e.g., A1 contains 11), the code block within the loop is skipped entirely and never runs. In contrast, a `Do...Loop While` structure would execute the code at least once before checking the condition.