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

I need to be able to list the names of the sheets contained in a workbook.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default list the sheets in a workbook

here is a vb.net example that should work for ya.

Dim sheet As Excel.Worksheet
Dim ODOC As Excel.Workbook

................

Dim worksheetname As String
For Each sheet In ODOC.Worksheets
Console.WriteLine(sheet.Name)
Next

"Listing of Excel shhets in a workbook" wrote:

I need to be able to list the names of the sheets contained in a workbook.

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

Function ListSheets() As String
For Each sht In ActiveWorkbook.Sheets
ListSheets = ListSheets & "," & sht.Name
Next
End Function

Sub aa()
MsgBox Mid(ListSheets, 2)
End Sub

Run the sub aa to get a comma delimited string containing the names of the
sheets. If you want to include worksheets only, replace ActiveWorkbook.Sheets
by ActiveWorkbook.Worksheets.

"Listing of Excel shhets in a workbook" wrote:

I need to be able to list the names of the sheets contained in a workbook.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default list the sheets in a workbook


Dim ODOC As Excel.Workbook
Dim sheet As Excel.Worksheet

.......
Dim worksheetname As String
For Each sheet In ODOC.Worksheets
Console.WriteLine(sheet.Name)
Next

"Listing of Excel shhets in a workbook" wrote:

I need to be able to list the names of the sheets contained in a workbook.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default list the sheets in a workbook

sStr = ""
for each sh in Activeworkbook.sheets
sStr = sStr & sh.Name & vbNewLine
Next
msgBox sStr

--
Regards,
Tom Ogilvy

"Listing of Excel shhets in a workbook" <Listing of Excel shhets in a
wrote in message
...
I need to be able to list the names of the sheets contained in a workbook.





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

Listing of Excel shhets in a workbook wrote:
I need to be able to list the names of the sheets contained in a workbook.

Here are a couple of ways:

Sub qwerty4()
'Workbook must have reference to Microsoft Scripting Runtime
Dim dic As Dictionary, rng As Range
Set dic = New Dictionary
Set rng = Range("A1:A" & ActiveWorkbook.Sheets.Count)
For Each sh In ActiveWorkbook.Sheets
dic.Add CStr(sh.Name), sh.Name
Next
rng.Value = Application.Transpose(dic.Items)
End Sub

Sub qwerty5()
Dim arr, rng As Range
Dim i As Integer, n As Integer, m As Object
Set m = ActiveWorkbook.Sheets
n = m.Count
Set rng = Range("A1:A" & n)
ReDim arr(1 To n, 1 To 1)
i = 1
For Each sh In m
arr(i, 1) = sh.Name
i = i + 1
Next
rng.Value = arr
End Sub

Alan Beban
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
Print list of names of all sheets in a workbook Jo Excel Discussion (Misc queries) 1 September 24th 09 05:00 PM
list sheets in workbook John Excel Discussion (Misc queries) 3 March 11th 09 03:58 AM
List all sheets present in Workbook Jeff Excel Worksheet Functions 6 November 9th 06 09:03 PM
Multiple Sheets (Need to create 500 individual sheets in one workbook, pulling DATA Amaxwell Excel Worksheet Functions 4 August 17th 06 06:23 AM
How do you list all the workbooks you have opened and the sheets in each workbook? Wendy[_3_] Excel Programming 1 December 5th 03 09:17 PM


All times are GMT +1. The time now is 12:23 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"