简体   繁体   中英

Is there a formula for a cell to return its own row number?

I am wondering if there is a way for a cell to reference its own row number in a formula.

I am using this formula to display text depending on a date that is input.

 =(IF($D2="","",(IF($D2=TODAY(),"Due Today!",(IF($D2<TODAY(),(TODAY()-$D2)&" Days Late",IF($D2>TODAY(),"Due in "&($D2-TODAY())&" Day(s)","")))))))     

Essentially, the workbook moves these entries around to different worksheets based on criteria that is input. However, when the macros move the entries around the cell references become inaccurate. For instance, while the above formula would be correct on the "main page" the D2 reference would become incorrect once the macro moves it to another worksheet.

Is there anyway to reference a cell in such a way where it will change depending on what row it is in? So instead of it looking at "D2" it will look at "DWhateverRowI'mIn"

Thanks!

您是否查看过Row Function =ROW ([reference]) eg =ROW(D23)将返回第23行。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM