ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   list sheets in range (https://www.excelbanter.com/excel-programming/382258-list-sheets-range.html)

J.W. Aldridge

list sheets in range
 
hi.


i have a code which i need to ammend.
I need to only list sheet names in between sheets named "start" &
"End".
I need the list to start in cell a22 on sheet "apples"



Sub listsheets()
For i = 1 To Worksheets.Count
Cells(i, "a") = Sheets(i).Name
Next i
End Sub



thanx


Tom Ogilvy

list sheets in range
 
Sub listsheets()
Dim i As Long, sh As Worksheet
Dim bWrite As Boolean
bWrite = False
i = 22
For Each sh In Worksheets
If bWrite Then
If LCase(sh.Name) < "end" Then
Worksheets("apples").Cells(i, "a").Value = sh.Name
i = i + 1
Else
bWrite = False
End If
End If
If LCase(sh.Name) = "start" Then
bWrite = True
End If
Next sh

End Sub

worked for me.

--
Regards,
Tom Ogilvy


"J.W. Aldridge" wrote:

hi.


i have a code which i need to ammend.
I need to only list sheet names in between sheets named "start" &
"End".
I need the list to start in cell a22 on sheet "apples"



Sub listsheets()
For i = 1 To Worksheets.Count
Cells(i, "a") = Sheets(i).Name
Next i
End Sub



thanx




All times are GMT +1. The time now is 12:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com