Hello,
I am new to VBA, but I am trying to come up with a code that sweeps the rows looking for specific keywords such as "GI " or "WI " and group those lines, I'm not sure what was my mistake because the code was working fine yesterday, then I uploaded it to a Cloud and now even if I download it to my desktop I am still getting Error 424 on line 5, but isn't GIStartRow and GIEndRow defined on line 3??
Sub GIGROUP()
Dim GIStartRow As Long, GIEndRow As Long
With Sheets("Linhas")
GIStartRow = Linhas.Range("B15:B500").Find(what:="GI *", after:=Linhas.Range("B15")).Row
GIEndRow = Linhas.Range("B15:B500").Find(what:="GI *", after:=Linhas.Range("B15"), searchdirection:=xlPrevious).Row
End With
Rows(GIStartRow & ":" & GIEndRow - 1).Select
Selection.Rows.GROUP
Dim WIStartRow As Long, WIEndRow As Long
With Sheets("Linhas")
WIStartRow = Linhas.Range("B15:B500").Find(what:="WI *", after:=Linhas.Range("B15")).Row
WIEndRow = Linhas.Range("B15:B500").Find(what:="WI *", after:=Linhas.Range("B15"), searchdirection:=xlPrevious).Row
End With
Rows(WIStartRow & ":" & WIEndRow - 1).Select
Selection.Rows.GROUP
Dim CWTStartRow As Long, CWTEndRow As Long
With Sheets("Linhas")
CWTStartRow = Linhas.Range("B15:B256").Find(what:="CWT *", after:=Linhas.Range("B15")).Row
CWTEndRow = Linhas.Range("B15:B256").Find(what:="CWT *", after:=Linhas.Range("B15"), searchdirection:=xlPrevious).Row
End With
Rows(CWTStartRow & ":" & CWTEndRow - 1).Select
Selection.Rows.GROUP
Dim GLStartRow As Long, GLEndRow As Long
With Sheets("Linhas")
GLStartRow = Linhas.Range("B15:B500").Find(what:="GL *", after:=Linhas.Range("B15")).Row
GLEndRow = Linhas.Range("B15:B500").Find(what:="GL *", after:=Linhas.Range("B15"), searchdirection:=xlPrevious).Row
End With
Rows(GLStartRow & ":" & GLEndRow - 1).Select
Selection.Rows.GROUP
End Sub