I have put together the following code, that is shown below. when I attempt to run it, I get the following error.
Compile error: Next without for
I do have the line, For Each Wks In Worksheets
Being that I am not a programmer, I do not understand, what is needed to fix current error.
Thank you in advance.
Sub Add_the_Formulas()
Dim Wks As Worksheet
Dim lngRow As Long, lngLastRow As Long
For Each Wks In Worksheets
If ws.Name <> "Teams-List" Then
Wks.Select
Range("C1").Formula = "=RIGHT(A1,LEN(A1)-FIND(""^^"",SUBSTITUTE(A1,""_"",""^^"",LEN(A1)-LEN(SUBSTITUTE(A1,""_"","""")))))"
Range("D5").Formula = "=LEFT(C1,LEN(C1)-(LEN(C1)-FIND(""@"",C1)+1))"
Range("D5").Formula = "=RIGHT(C1,LEN(C1)-SEARCH(""@"",C1,1)*1)"
Next Wks
End Sub
Compile error: Next without for
I do have the line, For Each Wks In Worksheets
Being that I am not a programmer, I do not understand, what is needed to fix current error.
Thank you in advance.
Sub Add_the_Formulas()
Dim Wks As Worksheet
Dim lngRow As Long, lngLastRow As Long
For Each Wks In Worksheets
If ws.Name <> "Teams-List" Then
Wks.Select
Range("C1").Formula = "=RIGHT(A1,LEN(A1)-FIND(""^^"",SUBSTITUTE(A1,""_"",""^^"",LEN(A1)-LEN(SUBSTITUTE(A1,""_"","""")))))"
Range("D5").Formula = "=LEFT(C1,LEN(C1)-(LEN(C1)-FIND(""@"",C1)+1))"
Range("D5").Formula = "=RIGHT(C1,LEN(C1)-SEARCH(""@"",C1,1)*1)"
Next Wks
End Sub