Storing a value on a cell dynamically

Status
Not open for further replies.

vladi305

Board Regular
Joined
Jan 12, 2023
Messages
88
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I'm trying to count from bottom to top the distance between 1 values. The 1 value represent an event on a particular date
the formula below when the event is found it extract the numeric value of the cell address and the difference of the previous value with the next one is the distance
so in cell A1 I store manually the value from the previous value of what I will use as the starting point. The idea will be to drag up the cursor and get the count
The question is how to set the value of the previous cell in A1 dynamically
As you notice the result on F17 is correct, the distance from F27 to F17 is 10 but from F17 to F3 is 14 NOT 24

To get the correct value the cell A1 would need to be updated when the formula reach the F3 cell

=LET(
lastVar, $A$1,
nextVar, TEXTJOIN("",TRUE,IFERROR((MID(CELL("address",INDEX($F17,MATCH(1,$E17,1))),ROW(INDIRECT("1:"&LEN(CELL("address",INDEX($F17,MATCH(1,$E17,1)))))),1)*1),"")),
IF(E17=1, lastVar - nextVar, ""))
 

Attachments

  • Pic44.jpg
    Pic44.jpg
    61.7 KB · Views: 10

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Duplicate to: How to calculate distance between values

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,592
Messages
6,120,433
Members
448,961
Latest member
nzskater

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