+ Reply to Thread
Results 1 to 5 of 5

Counter

  1. #1
    Sdbenn90
    Guest

    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. #2
    Bob Phillips
    Guest

    Re: 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" <Sdbenn90@discussions.microsoft.com> wrote in message
    news:B7C5217A-A70F-477C-9E2B-83E8702D29FE@microsoft.com...
    > 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. #3
    Sdbenn90
    Guest

    Re: 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" <Sdbenn90@discussions.microsoft.com> wrote in message
    > news:B7C5217A-A70F-477C-9E2B-83E8702D29FE@microsoft.com...
    > > 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. #4
    Bob Phillips
    Guest

    Re: 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 (Tools>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)

    "Sdbenn90" <Sdbenn90@discussions.microsoft.com> wrote in message
    news:D6CAF5DA-A929-408F-9053-5B45528F07A0@microsoft.com...
    > 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" <Sdbenn90@discussions.microsoft.com> wrote in message
    > > news:B7C5217A-A70F-477C-9E2B-83E8702D29FE@microsoft.com...
    > > > 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. #5
    Sdbenn90
    Guest

    Re: 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 (Tools>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)
    >
    > "Sdbenn90" <Sdbenn90@discussions.microsoft.com> wrote in message
    > news:D6CAF5DA-A929-408F-9053-5B45528F07A0@microsoft.com...
    > > 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" <Sdbenn90@discussions.microsoft.com> wrote in message
    > > > news:B7C5217A-A70F-477C-9E2B-83E8702D29FE@microsoft.com...
    > > > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1