+ Reply to Thread
Results 1 to 6 of 6

Macro based on Spin Button Linked cell value

  1. #1
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Macro based on Spin Button Linked cell value

    In the attached file you will see the explanation and wanted.

    Shortly, I need the code, which will run based on Spin Button Linked variable cell value.

    Waiting for help, thanks in advance for any reply.

    Regards.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Macro based on Spin Button Linked cell value

    I have a possible solution using Worksheet_Calculate() instead of Worksheet_Change(). The attached workbook was written and tested in Excel 2003, but should work in your version of Excel.

    To implement my solution:
    a. Add a cell in your sheet that references cell A1 for a calculation.
    I have cell 'A5' contain the formula '=A1'. This cell can probably be hidden.

    b. In a user module declare a global variable that contains the 'A1' value.
    The User Code can be in this module or in any User Module.

    Please Login or Register  to view this content.
    c. In the 'Sheet1' module put the Worksheet_Calculate(). This will fire your
    user defined Macros 1 thru 7.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Macro based on Spin Button Linked cell value

    Rather than messing with event code, you could assign a Macro like this (in a normal module) to the spin button.

    Please Login or Register  to view this content.
    You might want to put some code in to prevent routineOne from running again if spinner value is 1 and the down button is pressed.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Re: Macro based on Spin Button Linked cell value

    Thanks LJMetzger,

    Dear mikerickson, thanks for solution with so short code.

    But, I'd be very pleased if there is any code to prevent when SpinButton value 1 pressed down and SpinButton value 7 pressed up.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Macro based on Spin Button Linked cell value

    Something like this will work.
    Please Login or Register  to view this content.
    A spin button calling routines is most unusual. It cannot be used to call routineThree and then routineFive directly. Nor is it a intuative userinterface. You might consider two command buttons, a Run Next Routine and a Run Previous Routine button, their captions could be controlled so which routine is Next and Previous could be obvious to the user.

    If you create ButtonNext and ButtonPrevious and assign DoRoutine to both of them, it will do as the attached file.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mikerickson; 10-20-2013 at 11:25 AM.

  6. #6
    Forum Contributor
    Join Date
    11-10-2012
    Location
    istanbul
    MS-Off Ver
    Excel 2013
    Posts
    297

    Re: Macro based on Spin Button Linked cell value

    Thanks al lot mikerickson,

    Both are working.

    I am very grateful.

    Regards

+ 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. Spin Buttons - Linked Cell to update when copied?
    By svpdebbie in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-14-2017, 09:18 AM
  2. Spin Button / Macro
    By nogoodnames in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-14-2013, 11:05 AM
  3. [SOLVED] Excel 2007 : Spin Button Macro
    By traimaran in forum Excel General
    Replies: 2
    Last Post: 04-28-2012, 11:55 AM
  4. How to make the spin button's linked cell vary
    By Irascivel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-31-2009, 06:39 PM
  5. Spin Button:spin cells A7
    By ice in forum Excel General
    Replies: 1
    Last Post: 03-16-2007, 02:23 PM

Tags for this Thread

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