how do I set up a counter?

J

John T

I want to set up a cell which counts how many times a macro button has
been clicked. It also nees to be re-setable - presumably using
another macro.

Any suggestions

Cheers

John Taylor
"John Taylor's Freebies"
www.johnandgwyn.co.uk
(a free, teachers' resource website)

If replying by email take out "therubbish"
 
C

Chip Pearson

Use code like the following:

Sub IncrementCounter()
With ThisWorkbook.Worksheets("Sheet1").Range("A1") '<<< CHANGE
.Value = .Value + 1
End With
End Sub

Sub ResetCounter()
ThisWorkbook.Worksheets("Sheet1").Range("A1").Value = 0
End Sub

Assign IncrementCounter to your macro button, or call the function from the
code already attached to the button.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)
 
J

John T

Thanks for your help - it looks as though I'm going to have to do some
studying - never come across "Sub" or "code" before - presumably it's
a bit like defining procedures in old-fashioned BASIC.

I've just tried to find "sub" and "code in Steve Johnson's "Brilliant
Excel 2003" (published by Pearson Books) - not there!

Cheers

John T


t On Thu, 19 Oct 2006 13:34:51 -0500, "Chip Pearson"
 
J

John T

Wow I've just learnt hoe to use code! (sort of)
I've pasted your text in and adapted it and it works - MANY THANKS

Is it possible to make a count down timer - i.e. counting seconds down
to zero?

Cheers

John T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top