I am having difficulty assigning the range of the active cell's row to a ranged variable. When I attempt to copy this variable in a range function call, I get the "Method range of object global failed" error. Any tips?
Sub GroupLanes()
Dim Origin, Destination, ODPair As String
Dim mainWorkbook As Workbook
Dim Index As Long
Dim IB, OB As Range
Set mainWorkbook = ActiveWorkbook
Index = 6
Range("G" & Index).Select
Origin = ActiveCell.Value
Debug.Print Origin
Range("H" & Index).Select
Destination = ActiveCell.Value
Debug.Print Destination
Range("AV" & Index).Select
ODPair = ActiveCell.Value
Debug.Print ODPair
Do Until IsEmpty(ActiveCell)
Set IB = ActiveCell.EntireRow
Range("AV6").Select
ODPair = ActiveCell.Value
Do Until IsEmpty(ActiveCell)
If (Mid(ODPair, 1, 5) = Destination And Mid(ODPair, 6, 5) = Origin) Then
Set OB = ActiveCell.EntireRow
Range(IB).Copy
Sheets("Sheet2").Range("A" & Index & ":" & "AV" & Index).PasteSpecial xlPasteValues
Range(OB).Copy
Sheets("Sheet2").Range("A" & Index & ":" & "AV" & Index).PasteSpecial xlPasteValues
ActiveCell.Offset(1, 0).Select
ODPair = ActiveCell.Value
Else
ActiveCell.Offset(1, 0).Select
ODPair = ActiveCell.Value
Debug.Print ODPair
End If
Loop
Index = Index + 1
Range("G" & Index).Select
Origin = ActiveCell.Value
Range("H" & Index).Select
Destination = ActiveCell.Value
LoopEnd Sub