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.
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)
quot;Sdbenn90quot; gt; wrote in message
...
gt; I need help with either Excel or Visual basic Code to do the following.
gt;
gt; I need a command button if clicked by the user it will count the number of
gt; time the button was clicked. Also will need a reset button so the user can
gt; reset the number back to Zero if they need to start over. In Visual basic
I
gt; used the Static function which works but you have to end the form or sub
to
gt; reset the number. Any help with this matter is greatly appreciated.
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.
quot;Bob Phillipsquot; wrote:
gt; Add this code to a general module and just assign the macros to your
gt; buttons.
gt;
gt; Dim nCounter As Long
gt;
gt; Sub Count()
gt; nCounter = nCounter 1
gt; End Sub
gt;
gt; Sub ResetCount()
gt; nCounter = 0
gt; End Sub
gt;
gt;
gt; --
gt; HTH
gt;
gt; Bob Phillips
gt;
gt; (remove nothere from email address if mailing direct)
gt;
gt; quot;Sdbenn90quot; gt; wrote in message
gt; ...
gt; gt; I need help with either Excel or Visual basic Code to do the following.
gt; gt;
gt; gt; I need a command button if clicked by the user it will count the number of
gt; gt; time the button was clicked. Also will need a reset button so the user can
gt; gt; reset the number back to Zero if they need to start over. In Visual basic
gt; I
gt; gt; used the Static function which works but you have to end the form or sub
gt; to
gt; gt; reset the number. Any help with this matter is greatly appreciated.
gt;
gt;
gt;
Dim nCounter As Long
Sub Count()
nCounter = nCounter 1
Worksheets(quot;Sheet1quot;).Range(quot;A1quot;).Value = nCounter
End Sub
Sub ResetCount()
nCounter = 0
End Sub
To assign a button, make sure the Forms toolbar is visible (Toolsgt;Customize,
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)
quot;Sdbenn90quot; gt; wrote in message
news
gt; Thank You for the help, I'm still not sure on how it works. if I want the
gt; numbers to appear in A1. Where in the code do I tell it that A1 is where
this
gt; number to be displayed. if I insert a cmd button in C1, click the button
say
gt; 5 time 5 should appear in A1. and I aplogize how do I assign the macro to
the
gt; button.
gt;
gt; quot;Bob Phillipsquot; wrote:
gt;
gt; gt; Add this code to a general module and just assign the macros to your
gt; gt; buttons.
gt; gt;
gt; gt; Dim nCounter As Long
gt; gt;
gt; gt; Sub Count()
gt; gt; nCounter = nCounter 1
gt; gt; End Sub
gt; gt;
gt; gt; Sub ResetCount()
gt; gt; nCounter = 0
gt; gt; End Sub
gt; gt;
gt; gt;
gt; gt; --
gt; gt; HTH
gt; gt;
gt; gt; Bob Phillips
gt; gt;
gt; gt; (remove nothere from email address if mailing direct)
gt; gt;
gt; gt; quot;Sdbenn90quot; gt; wrote in message
gt; gt; ...
gt; gt; gt; I need help with either Excel or Visual basic Code to do the
following.
gt; gt; gt;
gt; gt; gt; I need a command button if clicked by the user it will count the
number of
gt; gt; gt; time the button was clicked. Also will need a reset button so the user
can
gt; gt; gt; reset the number back to Zero if they need to start over. In Visual
basic
gt; gt; I
gt; gt; gt; used the Static function which works but you have to end the form or
sub
gt; gt; to
gt; gt; gt; reset the number. Any help with this matter is greatly appreciated.
gt; gt;
gt; gt;
gt; gt;
Works Great. Thank you so much
quot;Bob Phillipsquot; wrote:
gt; Dim nCounter As Long
gt;
gt; Sub Count()
gt; nCounter = nCounter 1
gt; Worksheets(quot;Sheet1quot;).Range(quot;A1quot;).Value = nCounter
gt; End Sub
gt;
gt; Sub ResetCount()
gt; nCounter = 0
gt; End Sub
gt;
gt; To assign a button, make sure the Forms toolbar is visible (Toolsgt;Customize,
gt; click Forms) then drag the commandbutton onto your worksheet, and it will
gt; ask you to assign a macro, select Count.
gt;
gt; --
gt; HTH
gt;
gt; Bob Phillips
gt;
gt; (remove nothere from email address if mailing direct)
gt;
gt; quot;Sdbenn90quot; gt; wrote in message
gt; news
gt; gt; Thank You for the help, I'm still not sure on how it works. if I want the
gt; gt; numbers to appear in A1. Where in the code do I tell it that A1 is where
gt; this
gt; gt; number to be displayed. if I insert a cmd button in C1, click the button
gt; say
gt; gt; 5 time 5 should appear in A1. and I aplogize how do I assign the macro to
gt; the
gt; gt; button.
gt; gt;
gt; gt; quot;Bob Phillipsquot; wrote:
gt; gt;
gt; gt; gt; Add this code to a general module and just assign the macros to your
gt; gt; gt; buttons.
gt; gt; gt;
gt; gt; gt; Dim nCounter As Long
gt; gt; gt;
gt; gt; gt; Sub Count()
gt; gt; gt; nCounter = nCounter 1
gt; gt; gt; End Sub
gt; gt; gt;
gt; gt; gt; Sub ResetCount()
gt; gt; gt; nCounter = 0
gt; gt; gt; End Sub
gt; gt; gt;
gt; gt; gt;
gt; gt; gt; --
gt; gt; gt; HTH
gt; gt; gt;
gt; gt; gt; Bob Phillips
gt; gt; gt;
gt; gt; gt; (remove nothere from email address if mailing direct)
gt; gt; gt;
gt; gt; gt; quot;Sdbenn90quot; gt; wrote in message
gt; gt; gt; ...
gt; gt; gt; gt; I need help with either Excel or Visual basic Code to do the
gt; following.
gt; gt; gt; gt;
gt; gt; gt; gt; I need a command button if clicked by the user it will count the
gt; number of
gt; gt; gt; gt; time the button was clicked. Also will need a reset button so the user
gt; can
gt; gt; gt; gt; reset the number back to Zero if they need to start over. In Visual
gt; basic
gt; gt; gt; I
gt; gt; gt; gt; used the Static function which works but you have to end the form or
gt; sub
gt; gt; gt; to
gt; gt; gt; gt; reset the number. Any help with this matter is greatly appreciated.
gt; gt; gt;
gt; gt; gt;
gt; gt; gt;
gt;
gt;
gt;
- Feb 22 Thu 2007 20:35
Counter
close
全站熱搜
留言列表
發表留言