View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Hari Prasadh[_2_] Hari Prasadh[_2_] is offline
external usenet poster
 
Posts: 83
Default Programmatic indication of file to be PROCESSED.

Hi Bob,

Just a..

If I have 2 workbooks open (excluding personal.xls). One of the workbooks
have 8 sheets while the other one has 3. Both these contain data. I create a
new workbook by pressing Ctrl +N and if I run the macro then the macro
breaks at -- Set CurrentSheet = ActiveWorkbook.Worksheets(i) -- by
generating a -- Run time error '9' subscript error out of range.

If I comment the above statement and re-run the macro then it doesnt break.

And since a new workbook has 3 worksheets by default (as set in my system)
so in the macro when I hover my mouse over the value of i, it shows as 4. In
Immediate window if I type -- ?activeworkbook.name -- I get Book 1 -- and if
I type -- ?activesheet.name-- I get Sheet 1. Now, Book1 is the newly
created workbook (Ctrl +N) just before the running of the macro. Your code
is trying to access the fourth worksheet (i=4) within that workbook ?

Thanks a lot,
Hari
India