placing an x from a button into a cell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • golf32902
    New Member
    • May 2007
    • 17

    placing an x from a button into a cell

    How do you place an x into a cell by clicking a button?
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    It depends, if the command button is in a Form, just put it in the code:

    [CODE=vb]private sub commandbutton1_ click()
    dim row as long
    dim col as integer

    row = 1
    col = 1
    cells(row,col). value = "x" 'this will write an x in cell A1
    end sub[/CODE]

    If you are adding a button to your excel sheet, just write down a sub in a module, something like:

    [CODE=vb]sub anything()
    dim row as long
    dim col as integer

    row = 1
    col = 1
    cells(row,col). value = "x" 'this will write an x in cell A1
    end sub[/CODE]

    hope this helps

    Kad

    Comment

    • golf32902
      New Member
      • May 2007
      • 17

      #3
      Thanks it works great

      Comment

      • golf32902
        New Member
        • May 2007
        • 17

        #4
        to the same question is there a way to have it take the x out of anouther cell if you have it in anouther cell. for example i have a done and not done colums. II'm lookin to put an x in the not done cell and when it is done then i would like it to put an x in the done and get ride of the not done one. Thanks for all the help.

        Comment

        • kadghar
          Recognized Expert Top Contributor
          • Apr 2007
          • 1302

          #5
          Originally posted by golf32902
          to the same question is there a way to have it take the x out of anouther cell if you have it in anouther cell. for example i have a done and not done colums. II'm lookin to put an x in the not done cell and when it is done then i would like it to put an x in the done and get ride of the not done one. Thanks for all the help.
          Sure, just read carefuly the code:

          [CODE=vb]sub anything()
          dim row as long
          dim col as integer

          row = 1
          col = 1
          cells(row,col). value = "x" 'this will write an x in cell A1
          end sub[/CODE]
          where it says Row and Col, just change the number, if you want the cell B5 just put

          Row = 5
          Col = 2

          and if you want to clear the cell, instead of filling it with "x", just fill it with ""

          ;-) Good Luck

          Comment

          • golf32902
            New Member
            • May 2007
            • 17

            #6
            Thanks it worked great.

            Comment

            Working...