Auto count a cell

dtallent

New Member
Joined
Oct 1, 2018
Messages
9
I am tying to create a file in excel so that I can keep track of my daughter's volleyball stats. What I want to do is touch the screen and it will auto count, say it has 0, I touch the screen and it changes to 1, touch again and it goes to 2. I saw a macro that was created to allow the cell to change color, but I would rather it change to a number an keep counting as long as I touch he cell. Does anyone have a idea on how to do this? Below is the macro I found, but it just changes color.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'if cell fill is Blank, change to Brown
If Selection.Interior.Color = RGB(255, 255, 255) Then
Selection.Interior.Color = RGB(247, 150, 70)
GoTo Passem
End If
'if cell fill is Brown, change to Yellow
If Selection.Interior.Color = RGB(247, 150, 70) Then
Selection.Interior.Color = RGB(255, 255, 0)
GoTo Passem
End If
'If cell fill is Yellow, remove fill color
If Selection.Interior.Color = RGB(255, 255, 0) Then
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Passem:
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
You did not say what cell you wanted to select to keep the score.

This script works for Range("A1")
Modify if you want

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Modified  10/2/2018  6:40:57 AM  EDT
If Not Intersect(Target, Range("A1")) Is Nothing Then
If Target.Cells.CountLarge > 1 Then Exit Sub
Target.Value = Target.Value + 1
End If
End Sub
 
Upvote 0
This is perfect. Now do I change it all cells. I guess I should have said I need it to count multiple cells. It a spreadsheet with different columns.
 
Upvote 0
What does this mean:
Now do I change it all cells.

Excel Worksheet has 1.5 million rows and 16,384 column

So you want this script to apply to about 12 billion cells?

So any cell you click on should add up the values in that cell.
 
Upvote 0
What does this mean:
Now do I change it all cells.

Excel Worksheet has 1.5 million rows and 16,384 column

So you want this script to apply to about 12 billion cells?

So any cell you click on should add up the values in that cell.

That was a typo. I have been trying to figure out to edit. It meant to say how do I change the range to count all cells.
 
Upvote 0
Your original post said:
I am tying to create a file in excel so that I can keep track of my daughter's volleyball stats. What I want to do is touch the screen and it will auto count, say it has 0, I touch the screen and it changes to 1, touch again and it goes to 2.

In your last post you said:
That was a typo. I have been trying to figure out to edit. It meant to say how do I change the range to
count all cells.


Well again count all cells.

All cells???? all 12 billion cells.

How does the script know what cells to count and put the result where?


 
Upvote 0
Just the cells on the spreadsheet I have made, it is roughly c6 - c40 through column g. I think I may have figured it out. I change A1 to c6:g40 and it seems to work. I a sure there is an easier way.
 
Upvote 0
Easier way?
That gives you 176 cells to click on to add up score
Still not sure what your wanting.

But if this works for you that's great.
 
Upvote 0
Your original post said:
I am tying to create a file in excel so that I can keep track of my daughter's volleyball stats. What I want to do is touch the screen and it will auto count, say it has 0, I touch the screen and it changes to 1, touch again and it goes to 2.

In your last post you said:
That was a typo. I have been trying to figure out to edit. It meant to say how do I change the range to
count all cells.


Well again count all cells.

All cells???? all 12 billion cells.

How does the script know what cells to count and put the result where?



It's columns c6-c40 through column g. I may have figured this out but I also created 5 sheets on this one file. I have copied the script to each sheet but it only works on the first sheet.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top