VB or Excel VBA, accessing list of all the sheets in a workbook 
Author Message
 VB or Excel VBA, accessing list of all the sheets in a workbook

I wonder if somebody has solved this problem. I need to access a
list of all the sheets in an Excel 5.0 Workbook. I have no clue
whatsoever how this will be possible. Idas are welcome to, then
I can try them out.

TIA

Anders



Sat, 24 Jan 1998 03:00:00 GMT  
 VB or Excel VBA, accessing list of all the sheets in a workbook

says...

Quote:

>I wonder if somebody has solved this problem. I need to access a
>list of all the sheets in an Excel 5.0 Workbook. I have no clue
>whatsoever how this will be possible. Idas are welcome to, then
>I can try them out.

>TIA

>Anders

Following is a VBA example from the Excel Help File that shows how to get a
list of all the sheets, (modules, and charts) that are in an Excel Workbook,
by name.  You can also determine the type and only include the specific type
you are looking for.

Sub GetSheetNames()
   Dim SheetNames() As String
   Dim iCtr As Integer

   ReDim SheetNames(1 To ActiveWorkbook.Sheets.Count)
   x = 1
   For Each sht In ActiveWorkbook.Sheets
      SheetNames(x) = sht.Name
      Debug.Print SheetNames(x)   '--> can put in cell range, whatever
      x = x + 1
   Next
End Sub

Hope this helps.

Randy



Sat, 24 Jan 1998 03:00:00 GMT  
 VB or Excel VBA, accessing list of all the sheets in a workbook

Quote:

> I wonder if somebody has solved this problem. I need to access a
> list of all the sheets in an Excel 5.0 Workbook. I have no clue
> whatsoever how this will be possible. Idas are welcome to, then
> I can try them out.

Oh yeah, and the Object Worksheets() has a property "Name" if you need
the worksheet's name and not a reference for the worksheet its self.
---------------------------------------------------------------------------
Norman Storwick                        |
HealthCare COMPARE                     |
These opinions are, of course, my own. |


Sat, 24 Jan 1998 03:00:00 GMT  
 VB or Excel VBA, accessing list of all the sheets in a workbook

Quote:

> I wonder if somebody has solved this problem. I need to access a
> list of all the sheets in an Excel 5.0 Workbook. I have no clue
> whatsoever how this will be possible. Idas are welcome to, then
> I can try them out.

Its a little hard without knowing what you are doing, but perhaps the
following code will help

'  ForEachDemo
'  This routine uses the command For Each to  enter the string
'    "xyzzy" in the first cell of each sheet of the activeworkbook.

Sub ForEachDemo
     Dim sht                  'Variable to represent current worksheet

     For Each sht In Activeworkbook.Worksheets()
          sht.Cells(1,1).Value="xyzzy"
     Next
End Sub

Will this help?
---------------------------------------------------------------------------
Norman Storwick                        |
HealthCare COMPARE                     |
These opinions are, of course, my own. |



Sat, 24 Jan 1998 03:00:00 GMT  
 VB or Excel VBA, accessing list of all the sheets in a workbook
Thanks for your replys I'll try them out, what I want to do is,
getting a list of all the sheets from witch the user shall be
able to select a few or all sheets and then make a search for a
keyword on these sheets. Some kind of a search list.

Anders



Sun, 25 Jan 1998 03:00:00 GMT  
 VB or Excel VBA, accessing list of all the sheets in a workbook
Thanks for the answer I try it out, I want to perform a search
from a few randomly selected sheets.

Anders



Sun, 25 Jan 1998 03:00:00 GMT  
 VB or Excel VBA, accessing list of all the sheets in a workbook

Quote:

> I wonder if somebody has solved this problem. I need to access a
> list of all the sheets in an Excel 5.0 Workbook. I have no clue
> whatsoever how this will be possible. Idas are welcome to, then
> I can try them out.

In VB, I think you can use a DDE to access the sheets, but if you want to
use VBA (probably easier), you could do something like this :

Dim i as Integer           ' i is always an integer isn't it?

With ActiveWorkbook        ' or whichever book you like
   For i = 1 To .Sheets.Count    ' use .Worksheets if you only want them, Sheets
      .Sheets(i).Activate        ' includes Dialogs,ChartSheets and Modules
      With ActiveSheet
         'Do whatever sheet processing here
      End With
   Next i
End With

To easy eh? Try setting Application.ScreenUpdating to false before and
then true afterwards - stops that {*filter*} sheet flicking and speeds
processing up :)

scott

--
"To code or not to code, that is the question"
                               Scott Kinnane



Sun, 25 Jan 1998 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Excel VBA: search multiple-sheets in a workbook

2. Using Excel workbooks and sheet from Access

3. VBA: Excel workbook to workbook transfer

4. Getting the list of Excel Sheet Names using VBA

5. I want to email excel sheets in a workbook

6. Word2000 Mail merge from selected sheet in Excel workbook

7. Selecting multiple sheets in an Excel workbook

8. Err 1004: Excel Workbook/Sheet Activate

9. Copy an Excel sheet without opening the workbook.

10. Somebody please help me to create an Excel Workbook w/sheets from VB4.0

11. Write to, calculate, read from Excel workbook-sheet

12. ADO Connection to Excel - Finding the sheets in a workbook

 

 
Powered by phpBB® Forum Software