How to update formula for the next day by changing cell reference automatically?

greenpower78

New Member
Joined
Apr 24, 2021
Messages
8
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am trying to tackle a problem of updating a formula dynamically based on time. Suppose if a formula contains cell reference to a cell containing today's date, the cell reference should change automatically to the next adjacent cell, say to the right, containing tomorrow's date the next day. I don't want to manually change the cell reference all the time if I were to achieve automation. Is there a solution?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
In cases like this, seeing a sample of data and what you want to happen are usually most helpful (as data structure is critical to these questions). Could you post an example?

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Okay, here are the mini-sheets for your reference. What I am trying to do is I want the 'Last Clicked' column from the sheet 'RRClickspt1' to update whenever any clicks are made. If a user made a click today, the Last Clicked column cell will display "TODAY" for the corresponding username in the first sheet. The algorithm I used for determining if any clicks were made is to see if there is any difference between the clicks made today and the previous day for the corresponding user in the sheet 'RRClickspt2'. The date row is in the second sheet and each date column contains the total clicks made by each user and the total clicks are calculated in cumulative manner.

Similarly, if a user made clicks not today, but yesterday. I want the Last Clicked column's cell to display YESTERDAY. Finally if the user doesn't make any clicks today or made clicks yesterday, I want the cell to display the date on which the user last clicked. The number of total clicks made is manually inputted for each user.

Account.xlsx
ABCD
4UsernameReferral Since (Real)Last ClickedAvg. Clicks
5R969319324/8/21 12:10 PMFALSE1.632
6R318278325 4/23/21 1:13 AMYESTERDAY2.000
7R4677634933/31/21 9:38 PMYESTERDAY1.385
8R6578311064/8/21 12:10 PMFALSE1.263
9R8179664414/8/21 12:10 PMFALSE1.263
10R8690990583/31/21 9:38 PMTODAY1.885
RRClickspt1
Cell Formulas
RangeFormula
C5:C10C5=IF(AND(RRClickspt2!G$1=TODAY(),RRClickspt2!G2-RRClickspt2!F2>0),"TODAY",IF(AND(RRClickspt2!G$1=TODAY(),RRClickspt2!F2-RRClickspt2!E2>0),"YESTERDAY"))
D5:D10D5=MAX(OFFSET(RRClickspt2!$A2,0,1,1,COUNT(RRClickspt2!2:2)))/INT(NOW()-$B5)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D5:D10Cell Value>$B$2textNO
D5:D10Cell Value=$B$2textNO
D5:D10Cell Value<$B$2textNO

Account.xlsx
ABCDEFGH
1Username4/22/20214/23/20214/24/20214/25/20214/26/20214/27/20214/28/2021
2R96931932242831313131
3R318278325 004488
4R467763493333333333636
5R657831106162020242424
6R817966441122020242424
7R869099058424242424649
RRClickspt2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B1:AC1,B2:H7Expression=MOD(COLUMNS($B:B),7)=0textNO
 
Upvote 0
After lots of trial and errors modifying the IF function in the Last Clicked column of the first sheet, I managed to finally the solve the problem with the following formulas in the worksheet provided below. Since no one was able to provide a solution, I would like to share my own that I managed to find today.

Account.xlsx
ABCD
4UsernameReferral Since (Real)Last ClickedAvg. Clicks
5R969319324/8/21 12:10 PM4/24/211.550
6R318278325 4/23/21 1:13 AM4/26/211.600
7R4677634933/31/21 9:38 PM4/26/211.286
8R6578311064/8/21 12:10 PMTODAY1.400
9R8179664414/8/21 12:10 PM4/25/211.200
10R8690990583/31/21 9:38 PMTODAY1.857
RRClickspt1
Cell Formulas
RangeFormula
C5:C10C5=IF(AND(OFFSET(RRClickspt2!$A$1,0,MATCH(TODAY(),dates,0),1,1)=TODAY(),INDEX(RRClickspt2!2:2,,MATCH(TODAY(),dates,0)+1)-INDEX(RRClickspt2!2:2,,MATCH(TODAY(),dates,0))>0),"TODAY",IF(AND(OFFSET(RRClickspt2!$A$1,0,MATCH(TODAY(),dates,0),1,1)=TODAY(),INDEX(RRClickspt2!2:2,,MATCH(TODAY(),dates,0))-INDEX(RRClickspt2!2:2,,MATCH(TODAY(),dates,0)-1)>0),"YESTERDAY",INDEX(RRClickspt2!$1:$1,MATCH(LARGE(RRClickspt2!2:2,COUNTIF(RRClickspt2!2:2,MAX(RRClickspt2!2:2))+1),RRClickspt2!2:2,2)+1)))
D5:D10D5=MAX(OFFSET(RRClickspt2!$A2,0,1,1,COUNT(RRClickspt2!2:2)))/INT(NOW()-$B5)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D5:D10Cell Value>$B$2textNO
D5:D10Cell Value=$B$2textNO
D5:D10Cell Value<$B$2textNO


Account.xlsx
ABCDEFGH
1Username4/22/20214/23/20214/24/20214/25/20214/26/20214/27/20214/28/2021
2R9693193224283131313131
3R318278325 0044888
4R46776349333333333363636
5R65783110616202024242428
6R81796644112202024242424
7R86909905842424242464952
RRClickspt2


The formula I had to use to dynamically update Last Clicked column is

=IF(AND(OFFSET(RRClickspt2!$A$1,0,MATCH(TODAY(),dates,0),1,1)=TODAY(),INDEX(RRClickspt2!2:2,,MATCH(TODAY(),dates,0)+1)-INDEX(RRClickspt2!2:2,,MATCH(TODAY(),dates,0))>0),"TODAY",IF(AND(OFFSET(RRClickspt2!$A$1,0,MATCH(TODAY(),dates,0),1,1)=TODAY(),INDEX(RRClickspt2!2:2,,MATCH(TODAY(),dates,0))-INDEX(RRClickspt2!2:2,,MATCH(TODAY(),dates,0)-1)>0),"YESTERDAY",INDEX(RRClickspt2!$1:$1,MATCH(LARGE(RRClickspt2!2:2,COUNTIF(RRClickspt2!2:2,MAX(RRClickspt2!2:2))+1),RRClickspt2!2:2,2)+1)))

Yeah very lengthy one, but that's because I had to make sure any one of the three conditions are satisfied i.e, if any clicks are made today, it should display TODAY, else YESTERDAY, else the date someone last clicked. The INDEX and MATCH combination played a big role here to refer cells dynamically based on today's date. Here in the formula. 'dates' is simply the array name I gave from the 1st row in the second sheet excluding the cell A1 i.e., Username.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

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