close

Hi,

Thanks in advance.

Have a work sheet called summary.

In col B starting at row 11 I want to populate it with the names of
worksheets within the current file. (Excluding Summary).

The trick is I dont know how many worksheets there are.

Thanks

Trev

Hi Trev,

gt; In col B starting at row 11 I want to populate it with the names of
gt; worksheets within the current file. (Excluding Summary).

gt; The trick is I dont know how many worksheets there are.

Try:
'=============gt;gt;
Public Sub Tester()
Dim SH As Object
Dim i As Long

For Each SH In ThisWorkbook.Sheets
With SH
If UCase(.Name) lt;gt; quot;SUMMARYquot; Then
i = i 1
Sheets(quot;Summaryquot;).Range(quot;B11quot;)(i).Value = .Name
End If
End With
Next SH

End Sub
'lt;lt;=============---
Regards,
Norman
You could use a macro to accomplish that.

Sub test()
Dim WkSht As Worksheet
Dim Count As Long
Dim rngTarget As Range

Set rngTarget = Worksheets(quot;Summaryquot;).Range(quot;B11quot;)

For Each WkSht In Worksheets
If Not WkSht Is rngTarget.Parent Then
Count = Count 1
rngTarget(Count, 1).Value = WkSht.Name
End If
Next WkSht
End Sub

quot;Trever Bquot; wrote:

gt; Hi,
gt;
gt; Thanks in advance.
gt;
gt; Have a work sheet called summary.
gt;
gt; In col B starting at row 11 I want to populate it with the names of
gt; worksheets within the current file. (Excluding Summary).
gt;
gt; The trick is I dont know how many worksheets there are.
gt;
gt; Thanks
gt;
gt; Trev

全站熱搜
創作者介紹
創作者 software 的頭像
software

software

software 發表在 痞客邦 留言(0) 人氣()