+ Reply to Thread
Results 1 to 4 of 4

Adding Form Control Buttons

Hybrid View

  1. #1
    Registered User
    Join Date
    12-13-2012
    Location
    Louisiana
    MS-Off Ver
    Excel 2003
    Posts
    2

    Adding Form Control Buttons

    Trying to figure out the quick and easiest way to do this. I have 1000 cells that I need to add buttons that basically when you press the button associated with the cell will add 1 to the value. Is there an easy way to add these 1000 buttons?

    Thanks

  2. #2
    Forum Contributor
    Join Date
    07-27-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    198

    Re: Adding Form Control Buttons

    If you want to do this with one button, here is my
    suggestion. The attached uses a grid of 10 columns by 100 rows.
    Private Sub CommandButton1_Click()
    Dim cAddress As String
    Dim cCellNewValue As Long
        
        cAddress = ActiveCell.Address
        If ActiveCell.Row > 100 Or ActiveCell.Column > 10 Then GoTo Exit_CommandButton1_Click
        
        cCellNewValue = Range(cAddress).Value + 1
        Range(cAddress).Value = cCellNewValue
        
    Exit_CommandButton1_Click:
        
        Range(cAddress).Select
    
    End Sub
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    12-13-2012
    Location
    Louisiana
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Adding Form Control Buttons

    I need a button for each cell. so that the button linked to a certain cell can be pushed to add one to that cel.

  4. #4
    Forum Contributor
    Join Date
    07-27-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    198

    Re: Adding Form Control Buttons

    The attached Excel 2003 file contains a macro that will create a grid of command buttons.
    You can choose how many buttons, how many rows and columns, what cell they will start in,
    and the size. It is currently set up to create 80 buttons. A macro to delete the buttons is included.
    Follow the instructions and it should work for you to get your 1,000 buttons. 1,000 takes 2 to 3
    minutes to complete on my computer.

    I was not able to find a user-friendly way to write click event code directly into the worksheet
    module, so instead the code is written to a text file in the workbook's path, which you will need to
    open in Notepad and copy and paste it into the worksheet module. Each button’s click event code calls one
    procedure, which is in a separate module, and gives it the cell address to increment the value in the cell by 1.
    Attached Files Attached Files
    Last edited by xLJer; 12-15-2012 at 05:20 PM.

+ 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