View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
S G Booth S G Booth is offline
external usenet poster
 
Posts: 20
Default Load an array with Sheet names

Had ws already Dimmed as Worksheet, so this seems to work:

ReDim varr(1 To Worksheets.Count)
For i = 1 To UBound(varr)
varr(i) = Worksheets(i).Name
Next

Many thanks for your help.
Regards.

"Bob" wrote in message
...
Be sure you have: Set ws = Worksheets and change varr(i) = ws.Name to
read varr(i) = ws(i).Name. Also, take out: i = i + 1 (the Next satement
causes i to increment by one automatically)
"S G Booth" wrote:

varr is a Variant array. I wish to load it with names of sheets in the
activeworkbook.
I have:

If Global_PrintAllBooks_Sheets = True Then
ReDim varr(1 To Worksheets.Count)
For i = 1 To UBound(varr)
varr(i) = ws.Name
i = i + 1
Next

I receive run time error 91 (Object variable or With block variable not
set)
on varr(i) = ws.Name

Why is this please?

Regards.