Problem using named range in Offset

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,532
Office Version
  1. 365
Platform
  1. Windows
I thought I understood this from some previous discussions here, but apparently I do not.

This table shows three different ways to calculate the number of days between two dates. Column C has been assigned the name "Date".

The first one (Col D), uses relative cell addresses. The second uses the named range for the first term, but a cell reference in the Offset call. Both of these work.

The third one, which uses the named range in the Offset call, gets an error.

R/CCDEFGHI
5DateDaysFormulaDaysFormulaDaysFormula
6
4/06/20​
5D6: =C6-C75F6: =Date-OFFSET(C6,1,0)
#REF!​
H6: =Date-(OFFSET(Date,1,0))
7
4/01/20​
40D7: =C7-C840F7: =Date-OFFSET(C7,1,0)
#REF!​
H7: =Date-(OFFSET(Date,1,0))
8
2/21/20​
98D8: =C8-C998F8: =Date-OFFSET(C8,1,0)
#REF!​
H8: =Date-(OFFSET(Date,1,0))
9
11/15/19​
n/an/an/an/an/a

I tried several variations that I thought were suggested by various people here, but none of them work.

The expression
VBA Code:
=Date-(OFFSET(+Date,1,0))
, gets an error.

My attempt to use intersect operator,
VBA Code:
=Date-(row(H6)+1 Date)
, gets an error.

Is there a simple expression to subtract the date in the previous row from the one in the current row that uses only the named range (no cell references)?
 
This is because when you enter 7:7 in a formula, Excel interprets this as a range (row #7).

If you construct "7:7" as =ROW()&":"&ROW(), its a text string, not row #7, and =range string does not work. For it to work, the string should be wrapped in INDIRECT.
OK, I think I get it. It's confusing because Excel seems to go out of its way to treat text that looks like numbers as numbers, but then in some situations, it gets finicky.

jasonb75's solution is working great, so I am happy, but thanks for the little tutorial.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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