Consulting

Results 1 to 6 of 6

Thread: Trouble sorting as part of a Macro

  1. #1

    Trouble sorting as part of a Macro

    Hello, So I found some code that does the sorting that I want but when I try to run the Function as part of a macro the sorting does not work. Through a google search I found this code:

    Sub Sortmybin()
    Range("f2").CurrentRegion.Sort _
    Key1:=Range("f2").CurrentRegion.Sort _
    Order1:=XLDescending, _
    Header:=XLyes
    
    
    End Sub
    but I am getting a compile error for Expected end of Statement on the Order1 line.

    Any ideas?

    Thank you.
    Last edited by Bob Phillips; 10-27-2020 at 03:57 PM. Reason: Added code tags

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    Shouldn't it be

    Sub Sortmybin()
        Range("F2").CurrentRegion.Sort _
            Key1:=Range("F2"), _
            Order1:=xlDescending, _
            Header:=xlYes
    End Sub
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Yes sir that compiled. Now to see if it does what I am hoping. This is my first time using this forum. Do I owe you for your help?

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    Yes of course you owe me, I'll be round to your house for a beer, once life allows such things again
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Quote Originally Posted by Bob Phillips View Post
    Yes of course you owe me, I'll be round to your house for a beer, once life allows such things again

    Haha, you're on. Thank you very much.

    If I can't figure out how to do the little project I am working on would you be interested? But if it goes that route I insist in paying you more than some beers

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    If you do struggle, just PM me and I will check whether it warrants a gig, or whether it is just something to be addressed here on the forum (determined by the complexity).
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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