Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Sheet Names Array

Hi,

I need to create a function that returns an array of sheet tab names as
they appear on the screen in order from left to right. The array should
"exclude" the following two sheet names - "Addresses" and "CrossRef" and
should also exclude "hidden" sheets.

Does anyone have any ideas?
--
Regards,
Rocky McKinley



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Sheet Names Array

Rocky,

Try a function like the following:

Function SheetArray() As String()
Dim Arr() As String
Dim ndx As Long
Dim WS As Worksheet
For Each WS In Worksheets
If WS.Visible = xlSheetVisible Then
If WS.Name < "Addresses" And WS.Name < "CrossRef"
Then
ndx = ndx + 1
ReDim Preserve Arr(1 To ndx)
Arr(ndx) = WS.Name
End If
End If
Next WS
SheetArray = Arr
End Function

You can then call this function like

Dim Arr() As String
Dim ndx As Long
Arr = SheetArray()
For ndx = LBound(Arr) To UBound(Arr)
Debug.Print Arr(ndx)
Next ndx


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Rocky McKinley" wrote in message
...
Hi,

I need to create a function that returns an array of sheet tab

names as
they appear on the screen in order from left to right. The

array should
"exclude" the following two sheet names - "Addresses" and

"CrossRef" and
should also exclude "hidden" sheets.

Does anyone have any ideas?
--
Regards,
Rocky McKinley





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Sheet Names Array

Perfect Chip, thank you very much

--
Regards,
Rocky McKinley


"Chip Pearson" wrote in message
...
Rocky,

Try a function like the following:

Function SheetArray() As String()
Dim Arr() As String
Dim ndx As Long
Dim WS As Worksheet
For Each WS In Worksheets
If WS.Visible = xlSheetVisible Then
If WS.Name < "Addresses" And WS.Name < "CrossRef"
Then
ndx = ndx + 1
ReDim Preserve Arr(1 To ndx)
Arr(ndx) = WS.Name
End If
End If
Next WS
SheetArray = Arr
End Function

You can then call this function like

Dim Arr() As String
Dim ndx As Long
Arr = SheetArray()
For ndx = LBound(Arr) To UBound(Arr)
Debug.Print Arr(ndx)
Next ndx


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Rocky McKinley" wrote in message
...
Hi,

I need to create a function that returns an array of sheet tab

names as
they appear on the screen in order from left to right. The

array should
"exclude" the following two sheet names - "Addresses" and

"CrossRef" and
should also exclude "hidden" sheets.

Does anyone have any ideas?
--
Regards,
Rocky McKinley







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
Cell names = sheet names Vince Excel Worksheet Functions 9 February 8th 08 03:59 PM
XL2007 and array of sheet names? Jack Sheet Excel Discussion (Misc queries) 0 August 5th 06 02:57 PM
Place selected object names into array Tristan[_2_] Excel Programming 0 April 14th 04 10:36 AM
Create and Array formula using range names Carmen A Excel Programming 0 August 22nd 03 09:37 AM
Sorting Names in an Array Philippe Lhermie Excel Programming 6 July 20th 03 02:40 PM


All times are GMT +1. The time now is 06:59 PM.

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

About Us

"It's about Microsoft Excel"