Formula to increment a cell value by one

Seniornetman

New Member
Joined
Dec 14, 2023
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I am trying to create an automatic increment. the Formula I tried is =IF(OR(L2="P",L2="T"),G2+1,G2) I had it working but it was requiring me to have the values in 2 places to function and the source remained the same so it would not increment but once. If someone could give me the correct formula to increment the value in G2 by one when the P or T is entered in L2 I would really appreciate it. Thank You
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Maybe I don't quite understand what you mean, but your formula works for me.
Book1
GHLM
1G2 or G2+1
21P2
32T3
41a1
52b2
62c2
71d1
82e2
91f1
102g2
112h2
121i1
132P3
141T2
152f2
162T3
171h1
182r2
191P2
Sheet1
Cell Formulas
RangeFormula
M2:M19M2=IF(OR(L2="P",L2="T"),G2+1,G2)
 
Upvote 0
The number is in G2 already and I need it to increment in that Cell. I can put it in another cell and it will increment but then it won't do it again because the source cell does not increment. For some reason (probably because I am not that familiar with this, 25 years working on servers and networks and just making applications work but not really using them) When I put it in G2 it won't take a number. If I put it in L2 it doesn't work. I did get it to work but only when I put it in another cell that had the starting number in it and it worked but then I would have to manually change the other cell for it to increment again. This will be incrementing almost daily.
 
Upvote 0
I am trying to create an automatic increment. the Formula I tried is =IF(OR(L2="P",L2="T"),G2+1,G2) I had it working but it was requiring me to have the values in 2 places to function and the source remained the same so it would not increment but once. If someone could give me the correct formula to increment the value in G2 by one when the P or T is entered in L2 I would really appreciate it. Thank You
Maybe This will help G2 is the Day and L2 is the date. The other cells aren't involved.

DaySentenceER?D or MPoints
5/31/2024​
35​
45​
YesM
450​
27​
30​
YesM
300​
 
Upvote 0
Is this what you mean?
Book1
GL
1
21P
32T
42a
52b
62c
72d
82e
92f
102g
112h
122i
133P
144T
154f
165T
175h
185r
196P
Sheet3
Cell Formulas
RangeFormula
G2:G19G2=SCAN(0,L2:L19,LAMBDA(a,b,OR(b="P",b="T")+a))
Dynamic array formulas.
 
Last edited:
Upvote 0
The number is in G2 already and I need it to increment in that Cell.
That sounds like a circular reference. I think you need VBA to accomplish this. Unfortunately, I can't help you with that, but lots of wonderful people here are versed in it.
Edit to add: Where is the source and how does it relate to the P or T criteria in L2?
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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