+ Reply to Thread
Results 1 to 5 of 5

Auto sort macro for spin button event

  1. #1
    Registered User
    Join Date
    10-21-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Auto sort macro for spin button event

    Hello!

    I have learned how to create an auto sort macro based on cell changes within a range. The code works fine when manually changing these cells. However, the values in this range are typically updated by clicking a spin button (Active X).

    Unfortunately, the existing code does not auto sort when the cells are updated in this manner.

    Here is the code I use in the worksheet... I got a tip on another forum that I may need to change the even to Calculate, instead of Change. But when I make that change I receive a compile error.

    Please Login or Register  to view this content.

    ... and the code for the macro

    Please Login or Register  to view this content.


    Any suggestions on getting the auto sort macro to run when the Spin Button updates these values? I should probably mention that the spin button is on a different worksheet.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Auto sort macro for spin button event

    Use the change event of the spinbutton

    Please Login or Register  to view this content.



  3. #3
    Registered User
    Join Date
    10-21-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Auto sort macro for spin button event

    Gave it a try and it does not produce errors, but it does not sort the desired range upon spin button click.

    What does this part of the code you provided refer to? (I know I had that in my code but had borrowed that from another thread, so I'm not sure it is accurate)

    .Range("B4"),

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Auto sort macro for spin button event

    You have to check then name of the spinbutton : is it 'spinbutton1' ?
    Range B4 means the range will be sorted by column B. If you prefer A, then use .Range ("A4")

  5. #5
    Registered User
    Join Date
    10-21-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Auto sort macro for spin button event

    Aha! Actually your code was working fine, I just had to adjust the range up one row to account for a header. Thank you!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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