Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Tally" procedure in Excel 1

Status
Not open for further replies.

Conner

Technical User
Nov 29, 2000
44
0
0
US
The functio I need would let a user "click" on a cell and the cell would automatically add "1" to whatever value is already present. Each additional click would add 1 more...

Can this be done? User --- "click on cell"--value in cell increases by 1.
 
Have you tried to play with this event ?
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  If IsNumeric(Target.Value) Then
    Target.Value = Target.Value + 1
  End If
End Sub
You can play with the Address property of the Range object to be sure the cell double-clicked is one you want the behaviour for.


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Hi,

This can be done using the worksheet_selectionchange event

this incriments in column A
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Set rng = Application.Intersect(Target, Range("A:A"))
    If Not rng Is Nothing Then
        nMax = Application.Max(Range("A:A")) + 1
        If nMax > 0 Then
            With ActiveSheet.UsedRange
                r1 = .Row
                r2 = r1 + .Rows.Count
            End With
            If Target.Row <> r2 Then Exit Sub
        End If
        Target.Value = nMax
    End If
End Sub
:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
PHV, Skip

Thanks for the bit of code. I tried the solution PHV suggested first and it worked like a charm...Then I closed out the Excell Workbook to go to lunch, came back, and now the code doesn'w work. What happened?
 
What is the level of Macro security ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
You solved the problem. Security was on &quot;high.&quot; (Default?). Changed it to &quot;low&quot; because this is an internal application and tried it out. It worked. Gonna' field test it some more. Thanks. A star in your crown. This is saving this school system a ton of work in the way we have to tally our
business surveys...Again, Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top