#1   Report Post  
Posted to microsoft.public.excel.misc
Sdbenn90
 
Posts: n/a
Default Counter

I need help with either Excel or Visual basic Code to do the following.

I need a command button if clicked by the user it will count the number of
time the button was clicked. Also will need a reset button so the user can
reset the number back to Zero if they need to start over. In Visual basic I
used the Static function which works but you have to end the form or sub to
reset the number. Any help with this matter is greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Counter

Add this code to a general module and just assign the macros to your
buttons.

Dim nCounter As Long

Sub Count()
nCounter = nCounter + 1
End Sub

Sub ResetCount()
nCounter = 0
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Sdbenn90" wrote in message
...
I need help with either Excel or Visual basic Code to do the following.

I need a command button if clicked by the user it will count the number of
time the button was clicked. Also will need a reset button so the user can
reset the number back to Zero if they need to start over. In Visual basic

I
used the Static function which works but you have to end the form or sub

to
reset the number. Any help with this matter is greatly appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.misc
Sdbenn90
 
Posts: n/a
Default Counter

Thank You for the help, I'm still not sure on how it works. if I want the
numbers to appear in A1. Where in the code do I tell it that A1 is where this
number to be displayed. if I insert a cmd button in C1, click the button say
5 time 5 should appear in A1. and I aplogize how do I assign the macro to the
button.

"Bob Phillips" wrote:

Add this code to a general module and just assign the macros to your
buttons.

Dim nCounter As Long

Sub Count()
nCounter = nCounter + 1
End Sub

Sub ResetCount()
nCounter = 0
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Sdbenn90" wrote in message
...
I need help with either Excel or Visual basic Code to do the following.

I need a command button if clicked by the user it will count the number of
time the button was clicked. Also will need a reset button so the user can
reset the number back to Zero if they need to start over. In Visual basic

I
used the Static function which works but you have to end the form or sub

to
reset the number. Any help with this matter is greatly appreciated.




  #4   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default Counter

Dim nCounter As Long

Sub Count()
nCounter = nCounter + 1
Worksheets("Sheet1").Range("A1").Value = nCounter
End Sub

Sub ResetCount()
nCounter = 0
End Sub

To assign a button, make sure the Forms toolbar is visible (ToolsCustomize,
click Forms) then drag the commandbutton onto your worksheet, and it will
ask you to assign a macro, select Count.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Sdbenn90" wrote in message
...
Thank You for the help, I'm still not sure on how it works. if I want the
numbers to appear in A1. Where in the code do I tell it that A1 is where

this
number to be displayed. if I insert a cmd button in C1, click the button

say
5 time 5 should appear in A1. and I aplogize how do I assign the macro to

the
button.

"Bob Phillips" wrote:

Add this code to a general module and just assign the macros to your
buttons.

Dim nCounter As Long

Sub Count()
nCounter = nCounter + 1
End Sub

Sub ResetCount()
nCounter = 0
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Sdbenn90" wrote in message
...
I need help with either Excel or Visual basic Code to do the

following.

I need a command button if clicked by the user it will count the

number of
time the button was clicked. Also will need a reset button so the user

can
reset the number back to Zero if they need to start over. In Visual

basic
I
used the Static function which works but you have to end the form or

sub
to
reset the number. Any help with this matter is greatly appreciated.






  #5   Report Post  
Posted to microsoft.public.excel.misc
Sdbenn90
 
Posts: n/a
Default Counter

Works Great. Thank you so much

"Bob Phillips" wrote:

Dim nCounter As Long

Sub Count()
nCounter = nCounter + 1
Worksheets("Sheet1").Range("A1").Value = nCounter
End Sub

Sub ResetCount()
nCounter = 0
End Sub

To assign a button, make sure the Forms toolbar is visible (ToolsCustomize,
click Forms) then drag the commandbutton onto your worksheet, and it will
ask you to assign a macro, select Count.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Sdbenn90" wrote in message
...
Thank You for the help, I'm still not sure on how it works. if I want the
numbers to appear in A1. Where in the code do I tell it that A1 is where

this
number to be displayed. if I insert a cmd button in C1, click the button

say
5 time 5 should appear in A1. and I aplogize how do I assign the macro to

the
button.

"Bob Phillips" wrote:

Add this code to a general module and just assign the macros to your
buttons.

Dim nCounter As Long

Sub Count()
nCounter = nCounter + 1
End Sub

Sub ResetCount()
nCounter = 0
End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Sdbenn90" wrote in message
...
I need help with either Excel or Visual basic Code to do the

following.

I need a command button if clicked by the user it will count the

number of
time the button was clicked. Also will need a reset button so the user

can
reset the number back to Zero if they need to start over. In Visual

basic
I
used the Static function which works but you have to end the form or

sub
to
reset the number. Any help with this matter is greatly appreciated.






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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counter Polina Excel Discussion (Misc queries) 2 May 27th 05 09:52 PM
Did I stump everyone? Counter that ignores hidden rows TechMGR Excel Discussion (Misc queries) 2 April 5th 05 08:45 PM
Creating a counter that does not include hidden rows TechMGR Excel Discussion (Misc queries) 1 April 4th 05 10:11 PM
Row counter in formula jjpcpanama Excel Worksheet Functions 5 March 23rd 05 06:20 AM
Increment a counter in Excel COSdl Excel Worksheet Functions 2 March 4th 05 09:47 PM


All times are GMT +1. The time now is 11:27 AM.

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"