Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default list worksheets in a workbook.

I have a workbook that has upwards of 50 worksheets. Is there a simple way
of generating a list of those worksheets names? I don't fancy having to do
it manually?

TIA


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default list worksheets in a workbook.

you don't say where you want to list them, this will display them in the
immediate window
in the vb editor, do a control-G. if you want them in a specific place, post
back


Sub list_names()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
Debug.Print ws.Name
Next
End Sub

--


Gary


"mepetey" wrote in message
...
I have a workbook that has upwards of 50 worksheets. Is there a simple way of
generating a list of those worksheets names? I don't fancy having to do it
manually?

TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default list worksheets in a workbook.

Thanks for the fast response. I would like to insert them as a list in a
separate worksheet, and use as a validation list.

..


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
you don't say where you want to list them, this will display them in the
immediate window
in the vb editor, do a control-G. if you want them in a specific place,
post back


Sub list_names()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
Debug.Print ws.Name
Next
End Sub

--


Gary


"mepetey" wrote in message
...
I have a workbook that has upwards of 50 worksheets. Is there a simple way
of generating a list of those worksheets names? I don't fancy having to
do it manually?

TIA





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default list worksheets in a workbook.

try this
for i=1 to worksheets.count
cells(i,"a").value=sheets(i).name
next i

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"mepetey" wrote in message
...
I have a workbook that has upwards of 50 worksheets. Is there a simple way
of generating a list of those worksheets names? I don't fancy having to do
it manually?

TIA


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default list worksheets in a workbook.

then you can use something like one of these:

Sub list_names()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
Worksheets("Sheet1").Range("A" & ws.Index) = ws.Name
Next
End Sub

or

Sub list_names()
Dim i As Long

For i = 1 To Worksheets.Count
Worksheets("sheet1").Range("A" & i).Value = Worksheets(i).Name
Next
End Sub


--


Gary


"mepetey" wrote in message
...
Thanks for the fast response. I would like to insert them as a list in a
separate worksheet, and use as a validation list.

.


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
you don't say where you want to list them, this will display them in the
immediate window
in the vb editor, do a control-G. if you want them in a specific place, post
back


Sub list_names()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
Debug.Print ws.Name
Next
End Sub

--


Gary


"mepetey" wrote in message
...
I have a workbook that has upwards of 50 worksheets. Is there a simple way of
generating a list of those worksheets names? I don't fancy having to do it
manually?

TIA









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default list worksheets in a workbook.

I have a workbook that has upwards of 50 worksheets. Is there a simple way
of generating a list of those worksheets names? I don't fancy having to
do it manually?


This is something I use to generate a Table of Contents sheet in a workbook,
which includes a hyperlink to each sheet:

Sub TableOfContents()

Dim ws As Worksheet, wsTOC As Worksheet
Dim r As Long

Application.ScreenUpdating = False

For Each ws In ActiveWorkbook.Sheets

If ws.Name = "Table of Contents" Then
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
End If

Next ws

Set wsTOC =
ActiveWorkbook.Worksheets.Add(Befo=ActiveWorkbo ok.Sheets(1))
wsTOC.Name = "Table of Contents"
wsTOC.Range("A1") = "Table of Contents"
wsTOC.Range("A1").Font.Size = 18
r = 3

For Each ws In ActiveWorkbook.Worksheets

If ws.Name < wsTOC.Name Then
wsTOC.Hyperlinks.Add _
Anchor:=wsTOC.Cells(r, 1), _
Address:="", _
SubAddress:="'" & ws.Name & "'!A1", _
TextToDisplay:=ws.Name, ScreenTip:="Link to " & ws.Name
wsTOC.Cells(r, 1).Value = ws.Name
r = r + 1
End If

Next ws

Columns("A:A").EntireColumn.AutoFit
Cells.Font.Name = "Times New Roman"
Range("A1").Select
Application.CommandBars("Web").Visible = True
Application.ScreenUpdating = True

End Sub


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default list worksheets in a workbook.

Thanks to one and all for the help! much appreciated

"IanKR" wrote in message
...
I have a workbook that has upwards of 50 worksheets. Is there a simple
way of generating a list of those worksheets names? I don't fancy having
to do it manually?


This is something I use to generate a Table of Contents sheet in a
workbook, which includes a hyperlink to each sheet:

Sub TableOfContents()

Dim ws As Worksheet, wsTOC As Worksheet
Dim r As Long

Application.ScreenUpdating = False

For Each ws In ActiveWorkbook.Sheets

If ws.Name = "Table of Contents" Then
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
End If

Next ws

Set wsTOC =
ActiveWorkbook.Worksheets.Add(Befo=ActiveWorkbo ok.Sheets(1))
wsTOC.Name = "Table of Contents"
wsTOC.Range("A1") = "Table of Contents"
wsTOC.Range("A1").Font.Size = 18
r = 3

For Each ws In ActiveWorkbook.Worksheets

If ws.Name < wsTOC.Name Then
wsTOC.Hyperlinks.Add _
Anchor:=wsTOC.Cells(r, 1), _
Address:="", _
SubAddress:="'" & ws.Name & "'!A1", _
TextToDisplay:=ws.Name, ScreenTip:="Link to " & ws.Name
wsTOC.Cells(r, 1).Value = ws.Name
r = r + 1
End If

Next ws

Columns("A:A").EntireColumn.AutoFit
Cells.Font.Name = "Times New Roman"
Range("A1").Select
Application.CommandBars("Web").Visible = True
Application.ScreenUpdating = True

End Sub




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default A bit more coding is all I need.

The listing of worksheets is 99% of what I needed. What I would like to add are the contents from the B2, C21, and C32 cells from each worksheet.


Is this possible using your original source code?

CN



IanKR wrote:

This is something I use to generate a Table of Contents sheet in a workbook,
11-Nov-07

This is something I use to generate a Table of Contents sheet in a workbook,
which includes a hyperlink to each sheet:

Sub TableOfContents()

Dim ws As Worksheet, wsTOC As Worksheet
Dim r As Long

Application.ScreenUpdating = False

For Each ws In ActiveWorkbook.Sheets

If ws.Name = "Table of Contents" Then
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
End If

Next ws

Set wsTOC =
ActiveWorkbook.Worksheets.Add(Befo=ActiveWorkbo ok.Sheets(1))
wsTOC.Name = "Table of Contents"
wsTOC.Range("A1") = "Table of Contents"
wsTOC.Range("A1").Font.Size = 18
r = 3

For Each ws In ActiveWorkbook.Worksheets

If ws.Name < wsTOC.Name Then
wsTOC.Hyperlinks.Add _
Anchor:=wsTOC.Cells(r, 1), _
Address:="", _
SubAddress:="'" & ws.Name & "'!A1", _
TextToDisplay:=ws.Name, ScreenTip:="Link to " & ws.Name
wsTOC.Cells(r, 1).Value = ws.Name
r = r + 1
End If

Next ws

Columns("A:A").EntireColumn.AutoFit
Cells.Font.Name = "Times New Roman"
Range("A1").Select
Application.CommandBars("Web").Visible = True
Application.ScreenUpdating = True

End Sub

Previous Posts In This Thread:

On Saturday, November 10, 2007 3:46 PM
mepetey wrote:

list worksheets in a workbook.
I have a workbook that has upwards of 50 worksheets. Is there a simple way
of generating a list of those worksheets names? I do not fancy having to do
it manually?

TIA

On Saturday, November 10, 2007 3:58 PM
Gary Keramidas wrote:

you don't say where you want to list them, this will display them in the
you don't say where you want to list them, this will display them in the
immediate window
in the vb editor, do a control-G. if you want them in a specific place, post
back


Sub list_names()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
Debug.Print ws.Name
Next
End Sub

--


Gary


"mepetey" wrote in message
...

On Saturday, November 10, 2007 4:20 PM
mepetey wrote:

Thanks for the fast response.
Thanks for the fast response. I would like to insert them as a list in a
separate worksheet, and use as a validation list.

..

On Saturday, November 10, 2007 4:22 PM
Don Guillett wrote:

try thisfor i=1 to worksheets.countcells(i,"a").value=sheets(i).
try this
for i=1 to worksheets.count
cells(i,"a").value=sheets(i).name
next i

--
Don Guillett
Microsoft MVP Excel
SalesAid Software


On Saturday, November 10, 2007 4:38 PM
Gary Keramidas wrote:

list worksheets in a workbook.
then you can use something like one of these:

Sub list_names()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
Worksheets("Sheet1").Range("A" & ws.Index) = ws.Name
Next
End Sub

or

Sub list_names()
Dim i As Long

For i = 1 To Worksheets.Count
Worksheets("sheet1").Range("A" & i).Value = Worksheets(i).Name
Next
End Sub


--


Gary


"mepetey" wrote in message
...

On Sunday, November 11, 2007 7:40 AM
IanKR wrote:

This is something I use to generate a Table of Contents sheet in a workbook,
This is something I use to generate a Table of Contents sheet in a workbook,
which includes a hyperlink to each sheet:

Sub TableOfContents()

Dim ws As Worksheet, wsTOC As Worksheet
Dim r As Long

Application.ScreenUpdating = False

For Each ws In ActiveWorkbook.Sheets

If ws.Name = "Table of Contents" Then
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
End If

Next ws

Set wsTOC =
ActiveWorkbook.Worksheets.Add(Befo=ActiveWorkbo ok.Sheets(1))
wsTOC.Name = "Table of Contents"
wsTOC.Range("A1") = "Table of Contents"
wsTOC.Range("A1").Font.Size = 18
r = 3

For Each ws In ActiveWorkbook.Worksheets

If ws.Name < wsTOC.Name Then
wsTOC.Hyperlinks.Add _
Anchor:=wsTOC.Cells(r, 1), _
Address:="", _
SubAddress:="'" & ws.Name & "'!A1", _
TextToDisplay:=ws.Name, ScreenTip:="Link to " & ws.Name
wsTOC.Cells(r, 1).Value = ws.Name
r = r + 1
End If

Next ws

Columns("A:A").EntireColumn.AutoFit
Cells.Font.Name = "Times New Roman"
Range("A1").Select
Application.CommandBars("Web").Visible = True
Application.ScreenUpdating = True

End Sub

On Sunday, November 11, 2007 8:06 AM
mepetey wrote:

Thanks to one and all for the help!
Thanks to one and all for the help! much appreciated


Submitted via EggHeadCafe - Software Developer Portal of Choice
Using the WebResource.axd Handler with Embedded ASP.NET Resources
http://www.eggheadcafe.com/tutorials...sourceaxd.aspx
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
Creating a List From Worksheets in a WorkBook Carl Excel Worksheet Functions 1 August 30th 06 09:00 PM
List All Worksheets in Workbook sparx Excel Discussion (Misc queries) 7 February 28th 06 12:44 PM
Can I print a list of all of the worksheets within a workbook? SRsonn Excel Discussion (Misc queries) 1 June 29th 05 07:16 PM
Can I see a list of the worksheets within a workbook without scro. shrn Excel Worksheet Functions 3 March 26th 05 01:13 AM
List the worksheets in a workbook Kirk P. Excel Programming 2 December 28th 04 06:49 PM


All times are GMT +1. The time now is 02:19 PM.

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"