ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Excel VBA help (https://www.excelbanter.com/excel-worksheet-functions/144992-excel-vba-help.html)

tmobccr2

Excel VBA help
 
Greetings. I am trying to add a simple (or so it would seem) script
to an excel workbook, and having spent the weekend trying to find how,
am now turning to this group for help. I have created a command
button in a worksheet. I need this button to keep a tally, so to
speak. Essentially, I have one cell that is going to increase in
value by a factor of one each time the button is clicked. So, as an
example, cell B18 = 1. Command Button is clicked once, B18 now equals
2, etc. Can this be done via VB in excel? It would seem simple to
do, but I am stumped. Any help is appreciated. Thanks!


Bob Phillips

Excel VBA help
 
Sub Button1_Click()
With ActiveSheet.Range("B18")
.Value = .Value + 1
End With
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"tmobccr2" wrote in message
oups.com...
Greetings. I am trying to add a simple (or so it would seem) script
to an excel workbook, and having spent the weekend trying to find how,
am now turning to this group for help. I have created a command
button in a worksheet. I need this button to keep a tally, so to
speak. Essentially, I have one cell that is going to increase in
value by a factor of one each time the button is clicked. So, as an
example, cell B18 = 1. Command Button is clicked once, B18 now equals
2, etc. Can this be done via VB in excel? It would seem simple to
do, but I am stumped. Any help is appreciated. Thanks!




Ron Rosenfeld

Excel VBA help
 
On Sun, 03 Jun 2007 15:11:53 -0700, tmobccr2 wrote:

Greetings. I am trying to add a simple (or so it would seem) script
to an excel workbook, and having spent the weekend trying to find how,
am now turning to this group for help. I have created a command
button in a worksheet. I need this button to keep a tally, so to
speak. Essentially, I have one cell that is going to increase in
value by a factor of one each time the button is clicked. So, as an
example, cell B18 = 1. Command Button is clicked once, B18 now equals
2, etc. Can this be done via VB in excel? It would seem simple to
do, but I am stumped. Any help is appreciated. Thanks!


It should be simple. How did you create the button?
--ron

Gord Dibben

Excel VBA help
 
Have you looked at using a simple Spinner button from the Forms Toolbar?


Gord Dibben MS Excel MVP

On Sun, 03 Jun 2007 15:11:53 -0700, tmobccr2 wrote:

Greetings. I am trying to add a simple (or so it would seem) script
to an excel workbook, and having spent the weekend trying to find how,
am now turning to this group for help. I have created a command
button in a worksheet. I need this button to keep a tally, so to
speak. Essentially, I have one cell that is going to increase in
value by a factor of one each time the button is clicked. So, as an
example, cell B18 = 1. Command Button is clicked once, B18 now equals
2, etc. Can this be done via VB in excel? It would seem simple to
do, but I am stumped. Any help is appreciated. Thanks!



Don Guillett

Excel VBA help
 
Try this. Right click sheet tabview codeinsert this. Works on double_click
of cell b18 only

Option Explicit
Dim oldvalue As Double

Private Sub Worksheet_BeforeDoubleClick(ByVal target As Range, Cancel As
Boolean)
On Error GoTo fixit
Application.EnableEvents = False
if target.address<"$B$18" then exit sub
If target.Value = 0 Then oldvalue = 0
target.Value = 1 + oldvalue
oldvalue = target.Value
fixit:
Application.EnableEvents = True
End Sub

--
Don Guillett
SalesAid Software

"tmobccr2" wrote in message
oups.com...
Greetings. I am trying to add a simple (or so it would seem) script
to an excel workbook, and having spent the weekend trying to find how,
am now turning to this group for help. I have created a command
button in a worksheet. I need this button to keep a tally, so to
speak. Essentially, I have one cell that is going to increase in
value by a factor of one each time the button is clicked. So, as an
example, cell B18 = 1. Command Button is clicked once, B18 now equals
2, etc. Can this be done via VB in excel? It would seem simple to
do, but I am stumped. Any help is appreciated. Thanks!




All times are GMT +1. The time now is 01:59 AM.

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