Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Else without If? 1

Status
Not open for further replies.

fiel

Programmer
Jun 3, 2007
96
US
I'm not sure why, but I keep getting an Else without If error. Any ideas?

On Error Resume Next
Exists = Sheets("MCC" & x)
If Err.Number = 0 Then 'sheet exists so do nothing

Do
If y = x Then
y = y + 1
End If
While (Sheets(y) = Sheets(x))

Sheets("TempName").Select
Sheets("TempName").Name = "MCC " & x

Else 'sheet doesn't exist so assign it
'Renaming the sheet
Sheets("TempName").Select
Sheets("TempName").Name = "MCC " & x
End If
 
[!]Loop[/!] While (Sheets(y) = Sheets(x))

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top