I am inserting some new code into a working automation script that is attempting to add a new worksheet for each new value found in column I of the active worksheet. It works as a macro, but I'm trying to make it work inside of a stand-alone script. The code does not complie and gets hung up on line 19: Set WS = Sheets.Add(After:=Sheets(S
The error message issued is, Microsoft VBScript compilation error: Expected ')'
Can an Expert help me translate this into executable code for me?
' T E S T I N G - B E G I N
' Creates a new worksheet for every Level 1 value in Column I
' Also assumes presence of header rows in rows 1-2 of your source spreadsheet.
Set CLL = .Range("A3")
If Intersect(.UsedRange, .Range("I3:I65536")) Is Nothing Then
' Dont do anything
For Each CLL In Intersect(.UsedRange, .Range("I3:I65536"))
Set WS = Nothing
On Error Resume Next
Set WS = Sheets(CLL.Text)
On Error GoTo 0
If WS Is Nothing Then
Set WS = Sheets.Add(After:=Sheets(Sheets.Count))
WS.Name = IBU & "Aisle " & CLL.Text
CLL.EntireRow.Copy WS.Range("I65536").End(xlUp).Offset(1, 0).EntireRow
' T E S T I N G - E N D