list sheets in range

  • Thread starter Thread starter J.W. Aldridge
  • Start date Start date
J

J.W. Aldridge

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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top