VBA Excel Macro CodeThe following VBA Excel macro code shows how you can use a speadsheet instead of flash cards. This example uses the 50 states and their capitals. A state appears in column A and after a few seconds its capital appears in column B. 'Option Base 1 makes the arrays start at 1 instead of 0End of the VBA Excel macro code. The Do Loop first gets a random value between 1 and 50. The For Next block loops until we have a value that hasn't been displayed yet in the spreadsheet. It does this by checking each random value against the values that were already used and stored in the iUsed array... When it finds a value which is thus far unused, it exits the For Next loop and stores the value in the iUsed array. The A column on Sheet2 is then populated with the state from the A column from Sheet1. You then have 3 seconds to remember the state's capital. You will need to add the states to column A on Sheet1-one per line, and their capitals in column B of Sheet1... To just test the code, add a few and adjust the counters from 50 to x rows of test data and from 51 to x + 1. Before you run the macro, set Sheet2 as your active sheet. To stop the macro, press Ctrl-Break.
End of the VBA Excel macro code web page. Custom
Search
Return from VBA Excel Macro Code to VBA Code Samples |