Hi,
I have an issue with this macro but don't know why.
My table headers are all in Row 9 and I have frozen the pane just below it. I can select any cell from A10:J10 and down, run the macro and it sorts the cell's row ascending/descending taking the rest of the table with it. It all works fine but it won't sort anything below Row 301 - any ideas why??
Thanks
I have an issue with this macro but don't know why.
My table headers are all in Row 9 and I have frozen the pane just below it. I can select any cell from A10:J10 and down, run the macro and it sorts the cell's row ascending/descending taking the rest of the table with it. It all works fine but it won't sort anything below Row 301 - any ideas why??
Thanks
Code:
Sub Macro2()
Dim Rng As Range, col As Long, Rw As Long
Static Pos As Integer
Pos = IIf(Pos = xlAscending, xlDescending, xlAscending)
col = Selection.Column
Rw = Range("A10").CurrentRegion.Rows.Count
Set Rng = Range("A10:J" & Rw)
If Rng.Count > 1 Then Rng.Sort Cells(1, col), Pos
End Sub
Last edited: