Extracting MMYY from a MMDDYY cell then auto-populating ascending and descending MMYY cells

mspushypots

New Member
Joined
Mar 5, 2018
Messages
4
So I am not really sure how to ask this to search the board and Google is no help, so I am just going to post. I apologize if this has been answered before. Feel free to redirect me :)

I have a cell, #1 (A2) that I enter a date in. Cell #2 (AK) is set to =A2 and change the format to MMM YY. What I am wondering is if there a formula that I can use in the cells up and down from AK to convert the value in AK to the prior/subsequent month in the format shown. Or is there a better formula I can use for AK to make this easier? Or am I wishful thinking? :LOL: Thanks for any input here!

541ba9c0-fd06-459e-8ea3-a314efbf66c4
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Merge rows 1 & 2
Highlight B1 & B2 then right-click, Format Cells, Alignment, Merge cells. Then copy B1 and paste into rows 1 & 2 as far right as you want to go.

Enter Formulae
In AK1 put =A2

In AL1 put =DATE(YEAR(AK1),MONTH(AK1)+1,DAY(AK1)) then copy&paste that cell as far right as you want to go.

In AJ1 put =DATE(YEAR(AK1),MONTH(AK1)-1,DAY(AK1)) then copy&paste that cell as far left as you want to go.

Format Date & Orientation
Select B1 through as far right as you want to go, right-click, Format Cells, Number tab, Date and select type Mar-12. Alignment tab, Orientation 90 degrees, select OK.
 
Upvote 0
Hi,

One way:



AJ1 formula copied left, AL1 formula copied right.
 
Last edited:
Upvote 0
Hi,

One way:



AJ1 formula copied left, AL1 formula copied right.

My solution didn't post properly:


Book1
AAGAHAIAJAKALAMANAOAPAQAR
1This row Custom formatted mmm-yySep-16Oct-16Nov-16Dec-16Jan-17Feb-17Mar-17Apr-17May-17Jun-17Jul-17Aug-17
2January 4, 2017
Sheet10
Cell Formulas
RangeFormula
AJ1=EOMONTH(AK1,-2)+DAY(AK1)
AK1=A2
AL1=EOMONTH(AK1,0)+DAY(AK1)
 
Upvote 0
You're welcome, welcome to the forum.
 
Upvote 0
Thank you!
Are you sure that does what you want? For example, if you enter 31 January 2017 in A4 you will find two cells with Dec-16 and no cells with Feb-17 in AG1:AR1 (using post #5 screen shot range)

If you want 1 of each month consecutively then I would suggest
- in AJ1, copied left =EDATE(AK1,-1)
- in AL1, copied right =EDATE(AK1,1)

Edit: Actually, if you are trying to keep the 'day' part of the row 1 dates (even though the day is not displayed) as close to the A4 day as possible, then perhaps

AJ1: =EDATE($AK1,-COLUMNS(AJ1:$AJ1))
AL1: =EDATE($AK1,COLUMNS($AL1:AL1))
 
Last edited:
Upvote 0
Are you sure that does what you want? For example, if you enter 31 January 2017 in A4 you will find two cells with Dec-16 and no cells with Feb-17 in AG1:AR1 (using post #5 screen shot range)

If you want 1 of each month consecutively then I would suggest
- in AJ1, copied left =EDATE(AK1,-1)
- in AL1, copied right =EDATE(AK1,1)

Edit: Actually, if you are trying to keep the 'day' part of the row 1 dates (even though the day is not displayed) as close to the A4 day as possible, then perhaps

AJ1: =EDATE($AK1,-COLUMNS(AJ1:$AJ1))
AL1: =EDATE($AK1,COLUMNS($AL1:AL1))

Thank you! I haven't had time to go back to the spreadsheet so I will see how these all work out for me.
 
Upvote 0
You're right, that didn't come to mind when I posted, my formulas will possibly fail for 29th, 30th, & 31st day of the month.
If the OP don't care about the day, but just the month and year then a small adjustment to my formula should work, but I think your EDATE is better.


Book1
AAGAHAIAJAKALAMANAOAPAQAR
1This row Custom formatted mmm-yySep-17Oct-17Nov-17Dec-17Jan-18Feb-18Mar-18Apr-18May-18Jun-18Jul-18Aug-18
2January 1, 2018
Sheet10
Cell Formulas
RangeFormula
AJ1=EOMONTH(AK1,-1)
AK1=A2
AL1=EOMONTH(AK1,1)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,721
Messages
6,126,447
Members
449,314
Latest member
MrSabo83

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