+ Reply to Thread
Results 1 to 2 of 2

Dynamic Button based on Slide Bar Action

  1. #1
    Registered User
    Join Date
    11-29-2008
    Location
    Houston
    MS-Off Ver
    Office 2003, and 2007
    Posts
    77

    Dynamic Button based on Slide Bar Action

    I'm trying write some macro's in Excel 2003 and I'm stumped.

    I have a Slide Bar Shape from the Form Menu. When the slide bar moves, Cell C3 changes, and cells (D2, D3, and D4) change as a result of a formula that looks at C3. I have "Scroll Bar 1" assigned to macro "Sub ChBtn()" so that the caption text on the 3 buttons change based on the associated cell value in D2, D3, and D4.

    I'm using the below to change the button text, but it leaves the last button selected and looks goofy. I was hoping to use a "...with..." statement but can't seem to get that right.
    Please Login or Register  to view this content.
    What I want to do, is have the buttons execute a macro to navigate to a different sheet, but the sheet it navigates to depends on the cell value in D2, D3 and D4 that the buttons and scroll bar are on

    My problem is this:
    1. While the macro that changes the button name works, it looks sloppy. I thought I could use a "...with..." but could never figure it out.
    2. I'm trying to figure out how to pass the variable used with the "button name change" (Sub ChBtn()) to the macro that the button executes when it's clicked

    I've attached the spreadsheet for further clarification below.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Regards,
    Dan
    Real world knowledge isn't dropped from a parachute in the sky but rather acquired in tiny increments from a variety of sources including panic and curiosity.

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

    Re: Dynamic Button based on Slide Bar Action

    Hi Dan,

    Select is not usually needed in VBA code, except when you want to set the focus on something like a Sheet or a Cell.

    1. While the macro that changes the button name works, it looks sloppy. I thought I could use a "...with..." but could never figure it out.
    2. I'm trying to figure out how to pass the variable used with the "button name change" (Sub ChBtn()) to the macro that the button executes when it's clicked
    The attached file contain the following features.
    a. Simplified formulas in D2 thru D4.
    b. Modified Macro ChBtn() to remove the .Select construction.
    c. Added 'Double Click' Event for D2:D4 to go to Sheet.
    d. Added Macro GenericButtonClickEventHandler() to process CommandButton Clicks.
    e. Added Spinner also linked to cell C3.
    f. Added Module ModTools that contains the following Utility Macros:
    (1) RenameActiveShape()
    (2) LoopThroughShapes()
    (3) GetActiveShapeAttributes()
    (4) GetColorOfActiveCell()

    Please Login or Register  to view this content.
    Lewis
    Attached Files Attached Files

+ 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