rjplante
Well-known Member
- Joined
- Oct 31, 2008
- Messages
- 569
- Office Version
- 365
- Platform
- Windows
I am trying to write a for next loop and I am getting a "Compile Error: Syntax error" when I enter the phrase "Continue For".
I want the code to check the AX2 cell on each sheet, if the cell contains a "T" then I want it to execute to rest of the code. If it does NOT contain a "T" in AX2, then I want it to skip to the next sheet and check that one.
My code is below. What am I doing wrong here?
Thanks for any help provided!
I want the code to check the AX2 cell on each sheet, if the cell contains a "T" then I want it to execute to rest of the code. If it does NOT contain a "T" in AX2, then I want it to skip to the next sheet and check that one.
My code is below. What am I doing wrong here?
Code:
For Each xlSheet In ThisWorkbook.Sheets
If ActiveSheet.Range("AX2").Value <> "T" Then
Continue For
Else
If ActiveSheet.Name = "T-01 VAL-4840 Control Box" Then
ActiveSheet.Range("AM4").Value = 1
Else
ActiveSheet.Range("AM4").Value = Sheets(ActiveSheet.Index - 1).Range("AM4").Value + 1
ActiveSheet.Name = [CA1]
If ActiveSheet.Index < Worksheets.Count Then
Sheets(ActiveSheet.Index + 1).Activate
Else
Exit For
End If
End If
End If
Next xlSheet
Thanks for any help provided!