+ Reply to Thread
Results 1 to 10 of 10

Sort Macro Buttons

  1. #1
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Sort Macro Buttons

    Hi Everyone,

    I have a spreadsheet where I want to add two buttons. One button will sort Columns A & B based on Column (A) sorted A-Z. The other button will sort Columns A & B based on Column (B) sorted A-Z. I want all other columns to remain unchanged as they will be using vlookups based on the person's name that populates in column B. I'm having a hard time with it because Column A has merged cells which I need for the format. Any help or guidance would be greatly appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Sort Macro Buttons

    merged cells should be avoided wherever possible. you probably have to do some thing a bit contrived like this

    merge -> sort -> re-merge

    Please Login or Register  to view this content.
    'repeat above but for B instead of A
    Last edited by scottiex; 01-24-2018 at 05:36 PM.
    If you want something done right... find a forum and ask an online expert.

    Time flies like an arrow. Fruit flies like a banana.

  3. #3
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Sort Macro Buttons

    The Merge again portion is not working. Also, how else would you try and accomplish what I am accomplishing without having merged cells?

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Sort Macro Buttons

    Hi tkbuc,
    try this
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Sort Macro Buttons

    Are these individual macros? I'm not sure I am setting them up right. Can anyone put these how they are suppose to be in the excel file I attached in the OP so I can see their use?

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Sort Macro Buttons

    Here is your file with the code.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Sort Macro Buttons

    Thank you so much!!! For my information, what does "ertert" mean?

  8. #8
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Sort Macro Buttons

    it's just the name of the procedure

  9. #9
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Sort Macro Buttons

    Would you be able to walk me through one of the procedures step by step? I just want to know what it is actually doing as I'm trying to understand and educate myself

    Also, I tried adding a third column to sort on (new column C) and copied the procedures above and pasted it into VBA after ertertB and when pressed, it erases all of the data in column C? What did I do wrong?

    Sub ertertc()
    Dim x, i&, k&
    With Range("A2:c36")
    x = .Value: k = -6
    x = ShellSort22(x, 2) 'sort Columns A & B & C based on Column (C)
    For i = 1 To UBound(x)
    If Len(x(i, 1)) Then
    k = k + 7
    x(k, 1) = x(i, 1)
    x(k, 2) = x(i, 2)
    x(i, 1) = Empty: x(i, 2) = Empty
    End If
    Next i
    .Value = x
    End With
    End Sub
    Last edited by tkbuc; 01-26-2018 at 11:02 AM.

  10. #10
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Sort Macro Buttons

    *bump**bump*

+ 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. Macro buttons and Option buttons in same ark bugs?
    By Ugabuga in forum Excel General
    Replies: 0
    Last Post: 10-12-2014, 06:04 PM
  2. How to do sort with buttons in steps?
    By toplisek in forum Excel General
    Replies: 0
    Last Post: 01-10-2012, 10:58 AM
  3. Excel 2007 : How do I remove table sort buttons
    By allg in forum Excel General
    Replies: 3
    Last Post: 01-19-2010, 12:12 PM
  4. Create buttons to sort
    By sbs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-02-2006, 04:16 AM
  5. [SOLVED] Replacing macro buttons with a new set of buttons
    By jonco in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-02-2006, 08:40 PM
  6. Sort without moving buttons
    By David P. in forum Excel General
    Replies: 1
    Last Post: 07-02-2005, 08:05 PM
  7. [SOLVED] Adding buttons in a sheet to sort data
    By Jimbob in forum Excel General
    Replies: 1
    Last Post: 07-01-2005, 02:05 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