Is there a way to set the data range for a sort field range using a variable to find the last column and last row? I can set the variable for the last row, but when I try to use the cell property to set the range using variables for both last row and last column, the sort does not work. I have similar problems with other functions like setting print ranges.
Thanks,
Mike
Thanks,
Mike
Code:
Sub Sort_Report1()
Dim rRow As Long
Dim nCol As Integer
With Worksheets("Report1")
rRow = .Range("A" & Rows.Count).End(xlUp).Row 'Finds last data row
nCol = .Cells(1, 255).End(xlToLeft).Column
If rRow > 1 Then
'Sort Key: Date,Task Code
Worksheets("Report1").Range("A1:H" & rRow).Sort Key1:=Range("G1"), Key2:=Range("H1"), Order2:=xlAscending, Key3:=Range("A1"), Order1:=xlAscending, Header:=xlYes
End If
End With
End Sub