+ Reply to Thread
Results 1 to 7 of 7

creating a button that adds/subtracts

  1. #1
    Registered User
    Join Date
    06-17-2007
    Posts
    18

    creating a button that adds/subtracts

    i want to create two buttons within a workbook that adds (+1) to a value in a cell and one that subtracts (-1) the value in the same cell, i have been told that macros do this but i do not know enough knowledge about macros to configure it.

    can anyone help me please

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    It's actually not very hard.

    1. Go to VIEW-Toolbars-Control Toolbox
    2. There is an icon that is an arrow pointing up and one pointing down (if you hover your mouse over each icon, a name appears. You need the one named Spin Button).
    3. Select spin button and draw it whereever you would like.
    4. Right click on the spin button, and choose properties.
    5. There is a field named Linked Cell. Enter the cell that you want the spin button to affect.
    6. In the Control Toolbox, there is a green triangle. Click that.
    7. Test the spin button.

  3. #3
    Registered User
    Join Date
    06-17-2007
    Posts
    18
    superb, works just as i want it to

    many thanks

  4. #4
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    Happy to help.

  5. #5
    Registered User
    Join Date
    06-17-2007
    Posts
    18
    is there a way of seperating the buttons so they are two different ones?

  6. #6
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    It is a bit more complicated, but it is possible.

    1. Open the control toolbox (same instructions as before).
    2. This time, choose Command Button.
    3. Draw out a command button.
    4. Double Click the command button (this will take you to the VBA screen).
    5. Change the caption of the command button (this can be done in the properties window in the lower left corner. If the Properties window is not visible, press F4 to see it. On the field Caption, enter a plus sign (+) or whatever you would like.
    6. There will be a code box. It will say somehting like :Private sub Command.... and End sub. Between those two lines, enter this code:
    Dim i As Integer
    i = Range("b1").Value
    Range("b1") = i + 1
    NOTE: I chose B1 as my linked cell, change that to apply to the cell that you need.
    7. Repeat all of the steps above to make a minus command button, and enter the same code, except change the + 1 part to - 1.

    Let me know if that works.

  7. #7
    Registered User
    Join Date
    06-17-2007
    Posts
    18
    yes works a beauty!

    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