Code: Select all
Sub test()
Dim strHorses() As String ' Build an array of "In Form" trainers
Dim strJockeys() As String ' Build an array of "In Form" trainers
Dim strTrainers() As String ' Build an array of "In Form" trainers
MsgBox "pausing"
End Sub
It is probably of academic interest only, but may prove a bit of a time-saver for some.
Paste the code into a module and run it. Ho-hum.
Now set a Breakpoint on the MsgBox statement.
Run the macro; it stops on the MsgBox.
Place a ReDim strHorses(0) statement immediately before the MsgBox by
(1) Using ENTER to create a new line
(2) Double-clicking "strHorses" and Ctrl-C
(3) Typing "ReDim ", then Ctrl-V to paste in, then typing "(0)"
You now have a ReDim statement for the first array.
No sweat!
Now try to place a ReDim strJockeys(0) statement immediately before the MsgBox by
(4) Selecting the ReDim strHorses(0) statement
(5) Copy/Pasting it immediately before the MsgBox
I get the infamous alert message.
This has annoyed me ever since I learned I had to use ReDim statement to initialize arrays.
In the past I've shrugged, and rerun the application which, harvesting data from the web, could consume 45 minutes of my life.