Count only 1 time

gtd526

Well-known Member
Joined
Jul 30, 2013
Messages
657
Office Version
  1. 2019
Platform
  1. Windows
Hello,
Looking to perform a count, but when I hit 'save', it counts again.
How can I only count once, regardless of hitting 'save' (Q73).
Thank you.
NFL.xlsm
LMNOPQR
64ESPN Pick w/ +ATSCurrent W/L
65%SPRDW/LWLPsh
66DAL51%2.5W100
67CAR51%3W100
68    000
69    000
70"0" Loses
711
72ALL 0's
734
Weekly Picks
Cell Formulas
RangeFormula
L66L66=IFERROR(LOOKUP(2, 1/((COUNTIF($L$63:L63,$L$4:$L$35)=0)*($L$4:$L$35<>"")*($B$4:$B$35>0)),$L$4:$L$35),"")
M66:M69M66=IF(L66<>"",INDEX($M$4:$M$35,MATCH($L66,$L$4:$L$35,0)),"")
N66:N69N66=IF(L66<>"",INDEX($B$4:$B$35,MATCH($L66,$L$4:$L$35,0)),"")
O66:O69O66=IF(L66<>"",INDEX($D$4:$D$35,MATCH($L66,$A$4:$A$35,0)),"")
P66:P69P66=COUNTIFS($A$4:$A$35,$L66,$D$4:$D$35,"W")+R66*0.5
Q66:Q69Q66=COUNTIFS($A$4:$A$35,$L66,$D$4:$D$35,"L")+R66*0.5
R66:R69R66=COUNTIFS($A$4:$A$35,$L66,$D$4:$D$35,"Psh")
L67:L69L67=IFERROR(LOOKUP(2, 1/((COUNTIF($L$63:L66,$L$4:$L$35)=0)*($L$4:$L$35<>"")*($B$4:$B$35>0)),$L$4:$L$35),"")
Q71Q71=IF(AND(Q66=0,Q67=0,Q68=0,Q69=0),"1","0")
Q73Q73=Q71+Q73
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hello,
Looking to perform a count, but when I hit 'save', it counts again.
How can I only count once, regardless of hitting 'save' (Q73).
Thank you.
NFL.xlsm
LMNOPQR
64ESPN Pick w/ +ATSCurrent W/L
65%SPRDW/LWLPsh
66DAL51%2.5W100
67CAR51%3W100
68    000
69    000
70"0" Loses
711
72ALL 0's
734
Weekly Picks
Cell Formulas
RangeFormula
L66L66=IFERROR(LOOKUP(2, 1/((COUNTIF($L$63:L63,$L$4:$L$35)=0)*($L$4:$L$35<>"")*($B$4:$B$35>0)),$L$4:$L$35),"")
M66:M69M66=IF(L66<>"",INDEX($M$4:$M$35,MATCH($L66,$L$4:$L$35,0)),"")
N66:N69N66=IF(L66<>"",INDEX($B$4:$B$35,MATCH($L66,$L$4:$L$35,0)),"")
O66:O69O66=IF(L66<>"",INDEX($D$4:$D$35,MATCH($L66,$A$4:$A$35,0)),"")
P66:P69P66=COUNTIFS($A$4:$A$35,$L66,$D$4:$D$35,"W")+R66*0.5
Q66:Q69Q66=COUNTIFS($A$4:$A$35,$L66,$D$4:$D$35,"L")+R66*0.5
R66:R69R66=COUNTIFS($A$4:$A$35,$L66,$D$4:$D$35,"Psh")
L67:L69L67=IFERROR(LOOKUP(2, 1/((COUNTIF($L$63:L66,$L$4:$L$35)=0)*($L$4:$L$35<>"")*($B$4:$B$35>0)),$L$4:$L$35),"")
Q71Q71=IF(AND(Q66=0,Q67=0,Q68=0,Q69=0),"1","0")
Q73Q73=Q71+Q73
These are Win-Loss columns (P,Q). When you have 0 losses for all teams, count as 1. Every time there are 0 losses, add 1 to that count.
The W-L record will change daily. I already have a cell formula to count when there are 0 losses (Q71).
You can use any cell or number of cell to complete the task. It could even be a macro that would run each night (as WL record will change daily).
Q73 is just a test and can be ignored (it keeps counting when I hit 'save').
Thank you,
 
Upvote 0
I think your circular reference is causing the issue. I sounds like it is running multiple times.
There is nothing that would make sure that it only updates the count exactly once a day.

If if were me, I think I would use VBA and add a column that tracks the date it was last updated.
So the macro would only run/update the count if that stored date was not today, and after updating the count, update the date to today.

But some details will need to be determined in order to build that VBA code, such as:
1. When exactly is the data updated daily? Is that manual or automatic? We obviously would not want to run the count code until the data has been updated.
2. How exactly should this VBA code be run? If someone going to be opening the file everyday and running it? Or is an automated solution necessary? If so, what should trigger the code to run?

There may be other questions that arise, depending on the answers.
 
Upvote 0
I think your circular reference is causing the issue. I sounds like it is running multiple times.
There is nothing that would make sure that it only updates the count exactly once a day.

If if were me, I think I would use VBA and add a column that tracks the date it was last updated.
So the macro would only run/update the count if that stored date was not today, and after updating the count, update the date to today.

But some details will need to be determined in order to build that VBA code, such as:
1. When exactly is the data updated daily? Is that manual or automatic? We obviously would not want to run the count code until the data has been updated.
2. How exactly should this VBA code be run? If someone going to be opening the file everyday and running it? Or is an automated solution necessary? If so, what should trigger the code to run?

There may be other questions that arise, depending on the answers.
I found a macro that solves the problem.

VBA Code:
Dim d As Double
   
    d = Range("Q71").Value
    Range("Q73") = d + Range("Q73").Value

Thank you.
 
Last edited:
Upvote 0
Solution
Note that can be simplified to:
VBA Code:
    Range("Q73") = Range("Q71").Value + Range("Q73").Value
(no need to introduce variables when just adding two static cells together).

However, this still involves someone having to manually run the code, right?
And how do you ensure that it is only run once a day?
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,937
Members
449,094
Latest member
teemeren

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