Year from date

jarhead58

Active Member
Joined
Sep 21, 2017
Messages
367
Office Version
  1. 2021
Platform
  1. Windows
Hey everyone!! Hope you all had a great holiday season!!

I have J4 set with "=Mode(B4:B105)" which column B contain various numbers. Column A cells are dates, (A4=1/1/2019, A5=12/28/2018....etc going backward) How can I change the value of J4 ":B105" to the column B cell number closest to a year from the date of A4 or is it not possible? TIA
 
Amended to look at minus 1 year

=MODE(OFFSET(B4,,,MATCH(EDATE(A4,-12),A5:A10000,-1)))
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Amended to look at minus 1 year

=MODE(OFFSET(B4,,,MATCH(EDATE(A4,-12),A5:A10000,-1)))

Hmm...it gives me the value of J4 in the cell with this formula. I might be going about this the wrong way trying to explain this! The whole Mode(B4:B105) is just to find the number most indicated in that range. B105, I would like to change to B104 or B106, 7 whatever the row A104, A106, 7 value is in. For eg. if A4 is 1/1/19 and the closet date to it from a year ago is 1/3/18 and it's value is in A106 then I would like to have the B105 value to coincide with the A value, B106. Have I confused you entirely lol?
 
Upvote 0
That should be what it is doing.

The Match(Edate part matches the date in A4 (minus 12 mths), to the dates in range A5:A10000.
It returns the row number of the date that is closest (Same or greater than A4).
It uses this row number to create the range for Col B, e.g. B4:B106 (if row 106 is where it found the date match).

hth

Gaz
 
Upvote 0
That should be what it is doing.

The Match(Edate part matches the date in A4 (minus 12 mths), to the dates in range A5:A10000.
It returns the row number of the date that is closest (Same or greater than A4).
It uses this row number to create the range for Col B, e.g. B4:B106 (if row 106 is where it found the date match).

hth

Gaz

Here is a link to the test spreadsheet. https://1drv.ms/x/s!Apokzs4VeX3NtXXxDqV5WIW0iJgg
 
Upvote 0
Is the result wrong?

Yes, the B105 should change to B107, follow me?

Edited: The value of 6 will change eventually as the entries go on. I just need the formula to correct itself, if possible to fit the new date position.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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