Macro sort by ColA from A3 to BQ .Rows.Count

  • I have Column headers in rows 1 and 2. I'd like have a macro sort my data (Cols A:BQ) by the value in column A. I do not need a case-sensitive sort. The number of rows will vary so I need the macro to be able to detect how many rows there are and then sort the range A3 to BQ# where # is the number of rows.

    I tried to record the macro and then modify it but I keep getting errors. I currently only have 5 rows so the recorded macro defaults to BQ5, but if I add additional rows, it does not include the new rows.

    Thank you for your help.

  • Re: Macro sort by ColA from A3 to BQ .Rows.Count

    One way

    Sub test()
    With Range("a1").CurrentRegion
        With .Resize(.Rows.Count - 2).Offset(2)
            .Sort .Range("a1"), 1, Header:=xlNo
        End With
    End With
    End Sub
  • Re: Macro sort by ColA from A3 to BQ .Rows.Count

    What if a few columns do not have information entered? How can I ensure it will sort everything from the first to last column?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!