Making counters in excel

  • Thread starter Thread starter jehu
  • Start date Start date
J

jehu

Is there a way to get a box to behave as a counter, so that each time
you click on it the numerical value will increase by one. I am trying
to create a survey response sheet and this would be a big help.
 
ToolsMacro>Record New Macro>name it AddOne. Stop the macro recorder before
doing anything else; nothing should be recorded.
Tools>Macros>*Select the AddOne macro and click Edit.
Paste this on a line between the macro name/recorded date and End Sub:

Range("A1").Value = Range("A1") + 1

If you do not want to use cell A1, change the reference.
 
You could use a SelectionChange event procedure to do this. Enter the
following code in the sheet module for the appropriate worksheet. Change A1
to the correct cell address.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address(False, False) = "A1" Then
Range("A1").Value = Range("A1").Value + 1
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Range("A1").Value = Range("A1") + 1
Application.SendKeys "{ENTER}", True
End Sub

Works better for me; Change A1 to your cell; Whatever cell you decide on
Just Double-Click it and watch it "go-Up"!!!
HTH
 
I am not sure if it is better to double-click a cell to make the change or
single-click the button to achieve the same end. Personal preference, I
guess...
--
Greeting from the Gulf Coast!
http://myweb.cableone.net/twodays
JMay said:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Range("A1").Value = Range("A1") + 1
Application.SendKeys "{ENTER}", True
End Sub

Works better for me; Change A1 to your cell; Whatever cell you decide on
Just Double-Click it and watch it "go-Up"!!!
HTH
 
Back
Top