sort without limiting range

  • Recorded a macro to sort a list, but it has this line in it - Range ("W2:W16")
    Next time list likely to have different number of rows


    What should the code be to not be limited to a set range?



  • You could replace 16 by your own variable


    Code
    1. Dim last As Long
    2. last = Worksheets("Sheet1").Cells(Rows.Count, 23).End(xlUp).Row


    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)