Excel Sheet Names

L

Leo

Hi -

I am trying to write a code that allows me to add all
worksheet names into an array.

My array is defined as:
Dim SheetName (20) as String

I tried the following code but it doesn't seem to work:

For z = 1 to SheetCount

SheetName(z) = xlswb.Worksheets.Add

Next z

I am trying to look for a command that reads each 'tab' in
a workbook and 'sends' the name of each worksheet to my
array.

Please help.

Thanks
 
K

Ken Snell [MVP]

Change
SheetName(z) = xlswb.Worksheets.Add

to
SheetName(z) = xlswb.Worksheets(z).Name
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top