Thread: List worksheets
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Blue Blue is offline
external usenet poster
 
Posts: 7
Default List worksheets

Hi Halan

Thanks for the response. I can only get the first tab name to appear. I am
testing it in a workbook the four tabs, it names the first tab four times.
If I add a fifth worksheet it still only names the first tab four times
times. If I chnage the name of the first tab nothing happens. :o(

Blue

"Harlan Grove" wrote in message
oups.com...
Blue wrote...
I would like to list all the worksheet tab names starting in f5 going

down.

I would also like it to update if a tab name is changed or the order

of the
worksheets are rearranged is this possible.


Renaming worksheets triggers recalculation, so a UDF approach would be
the most efficient way to do this.


Function wsc(Optional rng As Range) As Variant
If rng Is Nothing Then Set rng = ActiveCell
wsc = rng.Parent.Parent.Worksheets.Count
End Function


Function wsl(Optional rng As Range) As Variant
Dim v As Variant, i As Long, n As Long
If rng Is Nothing Then Set rng = ActiveCell
With rng.Parent.Parent
ReDim v(1 To .Worksheets.Count)
For i = 1 To .Worksheets.Count
v(i) = .Worksheets(i).Name
Next i
End With
wsl = v
End Function


Then use it in a multiple cell array formula, e.g., select F5:F104 and
enter the array formula

=IF(ROW()-ROW($F$5)<wsc(),wsl(),"")