Thread: Do Until?
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Do Until?

Pam,

If i've understood correctly, try this

Sub listworksheets()
x = 6
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name = "Whatever" Then Exit Sub
Cells(x, 1).Value = ws.Name
x = x + 1
Next ws
End Sub

Mike

"Pam" wrote:

I'm fairly new at this..
I want to list all worksheets in my workbook until one named x.
I'm using this code:
Sub listworksheets()
x = 6
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
Cells(x, 1).Value = ws.Name
x = x + 1
Next ws

How do I change code to do what I want.

Thank you
End Sub