DIM problem
Good evening all,
In the following macro, I'm attempting to delete 20 worksheets from a
workbook that has, say 30 worksheets. When I run it, it deletes several
sheets, but then it crashes with a runtime error 9 (subscript out of range).
I know that an array has to be DIM'd, but I can't figure out the name of the
name of the array to be DIM'd. Is the array going to something like
"worksheets(50)"?? I've tried this and it doesn't work. Please help!
Thanks,
JW
Sub test()
Application.DisplayAlerts = False
For i = 1 To 20
ThisWorkbook.worksheets(i).Delete
Next i
Application.DisplayAlerts = True
End If
|