Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default List worksheet names

Hi,

I'm having trouble working out how to do this:

Loop through all worksheets in a workbook, returning the sheet names to a
range on the first sheet, i.e.
On sheet 1, cell A1 contains the name of the first worksheet, cell A2
contains the name of the second worksheet etc. Number of sheets is unknown.

Also to return the total number of sheets to cell B1.

Any thoughts?

Cheers,

Tom.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default List worksheet names

Try this to list names to the active sheet.

Sub listall()
x = 1
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
Cells(x, 1).Value = ws.Name
x = x + 1
Next ws
End Sub

Mike

"mr tom" wrote:

Hi,

I'm having trouble working out how to do this:

Loop through all worksheets in a workbook, returning the sheet names to a
range on the first sheet, i.e.
On sheet 1, cell A1 contains the name of the first worksheet, cell A2
contains the name of the second worksheet etc. Number of sheets is unknown.

Also to return the total number of sheets to cell B1.

Any thoughts?

Cheers,

Tom.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default List worksheet names

Fantastic.

Just the job.

Tom.

"Mike" wrote:

Try this to list names to the active sheet.

Sub listall()
x = 1
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
Cells(x, 1).Value = ws.Name
x = x + 1
Next ws
End Sub

Mike

"mr tom" wrote:

Hi,

I'm having trouble working out how to do this:

Loop through all worksheets in a workbook, returning the sheet names to a
range on the first sheet, i.e.
On sheet 1, cell A1 contains the name of the first worksheet, cell A2
contains the name of the second worksheet etc. Number of sheets is unknown.

Also to return the total number of sheets to cell B1.

Any thoughts?

Cheers,

Tom.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default List worksheet names

Sorry i missed the bit about the number of sheets. Add this line just before
the End Sub

Cells(1, 2).Value = x - 1

"Mike" wrote:

Try this to list names to the active sheet.

Sub listall()
x = 1
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
Cells(x, 1).Value = ws.Name
x = x + 1
Next ws
End Sub

Mike

"mr tom" wrote:

Hi,

I'm having trouble working out how to do this:

Loop through all worksheets in a workbook, returning the sheet names to a
range on the first sheet, i.e.
On sheet 1, cell A1 contains the name of the first worksheet, cell A2
contains the name of the second worksheet etc. Number of sheets is unknown.

Also to return the total number of sheets to cell B1.

Any thoughts?

Cheers,

Tom.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MAKE A LIST OF NAMES FROM REPEATED NAMES IN THE SAME WORKSHEET r.kordahi Excel Discussion (Misc queries) 2 January 3rd 09 08:10 AM
Referencing worksheet names from a list?? Ace70 Excel Discussion (Misc queries) 3 September 25th 08 04:54 AM
Trying to list tab/worksheet names in a summary worksheet Mich Excel Discussion (Misc queries) 1 February 7th 08 02:07 AM
List of worksheet names tor Excel Discussion (Misc queries) 4 March 20th 07 07:54 PM
want a list of selectable names on my worksheet Excel Worksheet Functions 4 August 7th 06 08:49 PM


All times are GMT +1. The time now is 06:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"