I have a macro that creates an increasing number of sheets as it runs. At each step it searches through these sheets to see if a certain one has been created in the workbook. Several workbooks are used in this macro and the code cycles though depending on the workbook. I want to speed up this process. The idea I have had is like this
On error goto notfound
with wkbtemp '=open workbook
found=true
worksheets(sheetfind).activate 'sheetfind=worksheet name
end with
notfound:
found=false
resume next
It should try to open the sheet if it is there then found = true if not it goes to error handler notfound and found=false.
The problem is that when I run it and it gets to the activate line i get an error (error handler disabled until it is running properly) even when I know the sheet exists.
Run time error 9
Subscript out of range.
I cant see what the problem is.
Any help appreciated
Andrew
It may have hit every branch on its way out of the ugly tree, but hey! It works. (but don't quote me on that)
On error goto notfound
with wkbtemp '=open workbook
found=true
worksheets(sheetfind).activate 'sheetfind=worksheet name
end with
notfound:
found=false
resume next
It should try to open the sheet if it is there then found = true if not it goes to error handler notfound and found=false.
The problem is that when I run it and it gets to the activate line i get an error (error handler disabled until it is running properly) even when I know the sheet exists.
Run time error 9
Subscript out of range.
I cant see what the problem is.
Any help appreciated
Andrew
It may have hit every branch on its way out of the ugly tree, but hey! It works. (but don't quote me on that)