+ Reply to Thread
Results 1 to 10 of 10

Sort range

  1. #1
    Registered User
    Join Date
    01-27-2020
    Location
    Delhi
    MS-Off Ver
    Office 365
    Posts
    26

    Sort range

    Hi,

    Please help me for sorting the range, i have applied the code but it is not working.

    Regards
    Sandeep Kumar

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Sort range

    How can we help without a sample of the data and the code you have used?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    01-27-2020
    Location
    Delhi
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Sort range

    Sir,


    Please find enclosed the attached file as refer in above.


    Regards
    Sandeep Kumar
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,522

    Re: Sort range

    1) Replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    2) You can delete 2 lines that selects the range.

  5. #5
    Registered User
    Join Date
    01-27-2020
    Location
    Delhi
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Sort range

    Thanks for the response.

    But it is not working, may you please put it on file and send me the updated file.


    Regards
    Sandeep Kumar

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,522

    Re: Sort range

    "Not working" is explaining nothing.
    How is it not working?

    I'm out and not with my PC.

    If you post your code after the change, I will see and if it is how I exactly suggested, I can not help you more.

  7. #7
    Registered User
    Join Date
    01-27-2020
    Location
    Delhi
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Sort range

    Sub Auto_filter()
    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets("Main")


    Dim dsh As Worksheet
    Set dsh = ThisWorkbook.Sheets("Data")

    dsh.UsedRange.Clear


    sh.AutoFilterMode = False

    '''''''' filter EMP - 1

    sh.Range("2:2").Select

    sh.Range("2:2").AutoFilter 28, "Delhi"


    sh.UsedRange.Copy dsh.Range("A1")

    sh.Range("aC3").Select

    sh.Range("Ac3", Range("Ac3").End(xlDown)).Sort Key1:=Range("AC3"), Order1:=xlAscending, Header:=xlNo


    dsh.Cells.Range("b2:BB10000").EntireColumn.AutoFit




    sh.AutoFilterMode = False



    End Sub

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,522

    Re: Sort range

    1)
    Administrative Note:

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    2)
    No, that is not what I suggested
    Read my post carefully.

  9. #9
    Registered User
    Join Date
    01-27-2020
    Location
    Delhi
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Sort range

    I apologize for the same.

    Hi Jindon,

    Here, please find the code in below.

    Sub Auto_filter()
    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets("Main")


    Dim dsh As Worksheet
    Set dsh = ThisWorkbook.Sheets("Data")

    dsh.UsedRange.Clear


    sh.AutoFilterMode = False

    '''''''' filter EMP - 1

    sh.Range("2:2").Select

    sh.Range("2:2").AutoFilter 28, "Delhi"


    sh.UsedRange.Copy dsh.Range("A1")

    sh.Range("aC3").Select

    sh.Range("Ac3", Range("Ac3").End(xlDown)).Sort Key1:=Range("AC3"), Order1:=xlAscending, Header:=xlNo


    dsh.Cells.Range("b2:BB10000").EntireColumn.AutoFit




    sh.AutoFilterMode = False



    End Sub


    Regards
    Sandeep Kumar

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,522

    Re: Sort range

    Quote Originally Posted by jindon View Post
    1) Replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    2) You can delete 2 lines that selects the range.
    "Replace" means delete the 1st line that you are currently have and insert the 2nd line instead that I suggested.

    Undersrand?
    Use the cide tags.!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 12
    Last Post: 09-08-2018, 10:34 PM
  2. Using custom sort orders with Range().sort
    By WestWindsDemon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-21-2018, 03:52 PM
  3. Cannot Sort Range VBA - "Unable to get sort property of range class"
    By jkj115 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2015, 04:51 PM
  4. [SOLVED] Issue with Sorting a Range: Sort method of Range class failed
    By helpmeinexcel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-12-2013, 01:51 PM
  5. sort button - how to sort large range in boxes
    By jw01 in forum Excel General
    Replies: 2
    Last Post: 03-06-2012, 09:35 PM
  6. Select 1st 2d range, sort, find 2nd, sort, etc
    By finny388 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-24-2011, 03:12 PM
  7. Replies: 1
    Last Post: 06-17-2006, 09:10 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1