#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default 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!

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default 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!



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default 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
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default 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!


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default 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!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"