Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to get a sheets name or list.

How to get a list of sheets name from a workbook (by selections, but not to
open it) so that I could make a selection on a sheet name I want.

Thanks in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to get a sheets name or list.

Hi Simon,

To make a list of sheets, try:

'================
Sub ListSheets()
Dim WB1 As Workbook, WB2 As Workbook
Dim SH As Worksheet
Dim i As Long

Set WB1 = ActiveWorkbook '<<=== CHANGE
Set WB2 = Workbooks("BbookToList.xls") '<<=== CHANGE

With WB1
Set SH = .Sheets.Add(after:=.Sheets(.Sheets.Count))
End With

For i = 1 To WB2.Sheets.Count
SH.Cells(i, "A").Value = WB2.Sheets(i).Name
Next i

End Sub
'<<================

To show a selectable popup list of sheets in the activeworkbook, try:

'================
Sub ShowSheetList()
'Jim Rech
On Error Resume Next
If ActiveWorkbook.sheets.Count <= 16 Then
Application.CommandBars("Workbook Tabs"). _
ShowPopup 500, 225
Else
Application.CommandBars("Workbook Tabs"). _
Controls("More Sheets...").Execute
End If
On Error GoTo 0
End Sub
'<<================

---
Regards,
Norman



"Simon Chang" wrote in message
...
How to get a list of sheets name from a workbook (by selections, but not
to
open it) so that I could make a selection on a sheet name I want.

Thanks in advance.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to get a sheets name or list.

Actually, I use "Application.GetOpenFilename" code to browse my workbooks
and pick any of them (but not to open them) which is from there I tries to
retrieve the sheets name. So I tried your codes by adding my codes but it
not respond to my code.

This is what I've tried:

Sub ShowSheetList()
'Jim Rech
mybook = Application.GetOpenFilename("Pick any workbook (*.xls), *.xls",
vbApplicationModal, "Good Luck")

On Error Resume Next
If mbook.Sheets.Count <= 16 Then
Application.CommandBars("Workbook Tabs"). _
ShowPopup 500, 225
Else
Application.CommandBars("Workbook Tabs"). _
Controls("More Sheets...").Execute
End If
On Error GoTo 0
End Sub

Your respond is on my appreciations and thanks in advance.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to get a sheets name or list.

Hi Simon,

The suggested code will not operate on a closed workbook.

If your intention is that the workbook should not be seen, perhaps you could
turn off screen updating, open the requisite workbook, list the sheet names,
close the workbook and then restore screen updating.

---
Regards,
Norman



"Simon Chang" wrote in message
...
Actually, I use "Application.GetOpenFilename" code to browse my workbooks
and pick any of them (but not to open them) which is from there I tries to
retrieve the sheets name. So I tried your codes by adding my codes but it
not respond to my code.

This is what I've tried:

Sub ShowSheetList()
'Jim Rech
mybook = Application.GetOpenFilename("Pick any workbook (*.xls), *.xls",
vbApplicationModal, "Good Luck")

On Error Resume Next
If mbook.Sheets.Count <= 16 Then
Application.CommandBars("Workbook Tabs"). _
ShowPopup 500, 225
Else
Application.CommandBars("Workbook Tabs"). _
Controls("More Sheets...").Execute
End If
On Error GoTo 0
End Sub

Your respond is on my appreciations and thanks in advance.




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
Getting 1 list from 2 sheets txheart Excel Discussion (Misc queries) 3 July 6th 11 05:24 PM
list totals for various sheets Tony H Excel Discussion (Misc queries) 3 December 15th 08 11:27 AM
List Sheets excluding sheets named ***-A Dolphinv4 Excel Discussion (Misc queries) 1 December 15th 07 09:29 AM
list of sheets svko Excel Worksheet Functions 1 July 13th 06 10:18 AM
List of Sheets Dnk Excel Programming 0 April 1st 04 02:59 PM


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