Results 1 to 3 of 3

Thread: help with sorting

  1. #1
    Conjurer Simi's Avatar
    Join Date
    Feb 2012
    Location
    Utah, USA
    Posts
    187
    Articles
    0

    help with sorting



    Register for a FREE account, and/
    or Log in to avoid these ads!

    I am trying to sort an unpredictable size of data on a form that I use.
    I always start on the same row,column but it will expand to an unknown size.
    I have used this as a hardcode for now but I have to modify the cells every time I run.
    ActiveSheet.Range("AS2:" & "AZ" & rowcnt).Sort Key1:=ActiveSheet.Range("AU2"), Order1:=xlDescending, Key2:=ActiveSheet.Range("AV2")

    I will always start my range in AS2 and will always sort by AU2 and AV2.
    I am trying to get a use of a variable for AZ in this example, sometimes it is AV and I have had as many as BE now.

    I have tried using the following but get an error. As a side note rowcnt is calculated before this code.
    Code:
    With ActiveSheet
        .Range(Cells(2, 45), Cells(rowcnt, 52)).Sort Key1:=ActiveSheet.Range(Cells(2, 47)), Order1:=xlDescending, Key2:=ActiveSheet.Range(Cells(2, 48))
    End With
    Any help is greatly appreciated.

    Thank you

    Simi
    Last edited by Simi; 2014-01-08 at 11:31 PM.

  2. #2
    Conjurer snb's Avatar
    Join Date
    May 2013
    Posts
    374
    Articles
    0
    Excel Version
    2020
    Dive into the VBEditor's helpfiles, lemma 'currentregion'

  3. #3
    Yes correct.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •