ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simpel commandbutton question (https://www.excelbanter.com/excel-programming/339506-simpel-commandbutton-question.html)

Andy T via OfficeKB.com

Simpel commandbutton question
 
Is it possible to create a commandbutton that ads 1 to a specific cell (say
A1) each time you press it?

David Hepner

Simpel commandbutton question
 
Try this:

Private Sub CommandButton1_Click()
Dim x As Long
x = Range("a1").Value
x = x + 1
Range("a1").Value = x

End Sub


"Andy T via OfficeKB.com" wrote:

Is it possible to create a commandbutton that ads 1 to a specific cell (say
A1) each time you press it?


Brtw

Simpel commandbutton question
 
' Application.CommandBars("Forms").Visible = True
' ActiveSheet.Buttons.Add(172.5, 25.5, 52.5, 52.5).Select
' Application.Goto Reference:="Macro1"
Dim count As Integer
Range("B3") = Range("B3").Value + 1

The first 3 lines are commented because I recorded adding a button to
the spreadsheet, then going into the macro editor. B3 is the cell I'm
adding one too each button push.


Andy T via OfficeKB.com

Simpel commandbutton question
 
Thanks alot both of you, it works fine


--
Message posted via http://www.officekb.com


All times are GMT +1. The time now is 06:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com