Get the Correct Month

MrDB4Excel

Active Member
Joined
Jan 29, 2004
Messages
348
Office Version
  1. 2013
Platform
  1. Windows
Cell AA4’s formula is =IFERROR(LOOKUP(2,1/(B4:Y4<>""),B4:Y4),"xx")
Cells B2:Y2 indicate a specific month an action was performed per the result in AA4.
When the value in AA4 comes from October then the value in AD4 should read October.
When the value in AA4 comes from November then the value in AD4 should read November, this I have not been able to figure out how to do.
So basically any value in column AM needs to get the correct month for the date value in column AP based upon which month column the Action was last done.
1st, 2nd, 3rd, 4th, 5th, & 6th indicate which week of the month the indicated date occurs within. This is done because in some months no action occurs in any given week of the month as indicated by the Xl2bb Mini Sheet. And in some months any given action may occur in more than one week of the month thus the need for a separate column for each week of the month.
As you can see in the Xl2bb Mini Sheet some values in the November range, 2nd week, do not give correct results in Column AD.
I have explored multiple methods and just can’t seem to find a good method.
Perhaps I don’t have enough if statements.
Any help will be much appreciated.
Following this description you will find two Mini Sheets. The second Mini Sheet is simply the calendar.

BogusSchedule2024_Chngs.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG
2SeptemberOctoberNovemberDecemberNovember 06, 202411October6October
31st2nd3rd4th5th6th1st2nd3rd4th5th6th1st2nd3rd4th5th6th1st2nd3rd4th5th6th2024November11/6/2024
4Action 0172828October 28, 2024October 28, 2024
5Action 0216279182866November 28, 2024November 28, 2024
6Action 0316279182877October 28, 2024
7Action 0416279182866November 28, 2024
8Action 0562488October 28, 2024246$K$8
9Action 06168182855October 28, 2024
10Action 071818October 28, 2024
11Action 081699October 28, 2024
12Action 098182855October 28, 2024
13Action 108182855October 28, 2024
14Action 11xx 
Sheet1
Cell Formulas
RangeFormula
AA2AA2=TEXT($AD$3&" "&AA5&", "&$AA$3,"mmmm dd, yyyy")
AB2AB2=MONTH(AE3)
AG2AG2=TEXT(EOMONTH(TODAY(),-1),"mmmm")
AE2AE2=DAY(AE3)
AE3AE3=TODAY()
AG4AG4=TEXT($AD$2&" "&$AA4&", "&$AA$3,"mmmm dd, yyyy")
AG5AG5=TEXT($AD$3&" "&$AA4&", "&$AA$3,"mmmm dd, yyyy")
AE8AE8=MAX($B$8:$Y$8)
AF8AF8=OFFSET($K$8,0,-2)
AG8AG8=CELL("address",INDEX($B$8:$Y$8,MATCH(MAX($B$8:$Y$8),$B$8:$Y$8,0)))
AA4:AA14AA4=IFERROR(LOOKUP(2,1/(B4:Y4<>""),B4:Y4),"xx")
AD2AD2=TEXT(TODAY()-DAY(TODAY()),"mmmm")
AD3AD3=TEXT($AB$2*29,"mmmm")
AD4:AD14AD4=IF($AA4="xx","",IF($AA4<>$AE$2,$AG$4,IF($AA4=$AE$2,$AG$5)))


The second Mini Sheet must appear in a follow-up to this post as I received the message "Generated content exceeds the limit..."
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Cell AA4’s formula is =IFERROR(LOOKUP(2,1/(B4:Y4<>""),B4:Y4),"xx")
Cells B2:Y2 indicate a specific month an action was performed per the result in AA4.
When the value in AA4 comes from October then the value in AD4 should read October.
When the value in AA4 comes from November then the value in AD4 should read November, this I have not been able to figure out how to do.
So basically any value in column AM needs to get the correct month for the date value in column AP based upon which month column the Action was last done.
1st, 2nd, 3rd, 4th, 5th, & 6th indicate which week of the month the indicated date occurs within. This is done because in some months no action occurs in any given week of the month as indicated by the Xl2bb Mini Sheet. And in some months any given action may occur in more than one week of the month thus the need for a separate column for each week of the month.
As you can see in the Xl2bb Mini Sheet some values in the November range, 2nd week, do not give correct results in Column AD.
I have explored multiple methods and just can’t seem to find a good method.
Perhaps I don’t have enough if statements.
Any help will be much appreciated.
Following this description you will find two Mini Sheets. The second Mini Sheet is simply the calendar.

BogusSchedule2024_Chngs.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG
2SeptemberOctoberNovemberDecemberNovember 06, 202411October6October
31st2nd3rd4th5th6th1st2nd3rd4th5th6th1st2nd3rd4th5th6th1st2nd3rd4th5th6th2024November11/6/2024
4Action 0172828October 28, 2024October 28, 2024
5Action 0216279182866November 28, 2024November 28, 2024
6Action 0316279182877October 28, 2024
7Action 0416279182866November 28, 2024
8Action 0562488October 28, 2024246$K$8
9Action 06168182855October 28, 2024
10Action 071818October 28, 2024
11Action 081699October 28, 2024
12Action 098182855October 28, 2024
13Action 108182855October 28, 2024
14Action 11xx 
Sheet1
Cell Formulas
RangeFormula
AA2AA2=TEXT($AD$3&" "&AA5&", "&$AA$3,"mmmm dd, yyyy")
AB2AB2=MONTH(AE3)
AG2AG2=TEXT(EOMONTH(TODAY(),-1),"mmmm")
AE2AE2=DAY(AE3)
AE3AE3=TODAY()
AG4AG4=TEXT($AD$2&" "&$AA4&", "&$AA$3,"mmmm dd, yyyy")
AG5AG5=TEXT($AD$3&" "&$AA4&", "&$AA$3,"mmmm dd, yyyy")
AE8AE8=MAX($B$8:$Y$8)
AF8AF8=OFFSET($K$8,0,-2)
AG8AG8=CELL("address",INDEX($B$8:$Y$8,MATCH(MAX($B$8:$Y$8),$B$8:$Y$8,0)))
AA4:AA14AA4=IFERROR(LOOKUP(2,1/(B4:Y4<>""),B4:Y4),"xx")
AD2AD2=TEXT(TODAY()-DAY(TODAY()),"mmmm")
AD3AD3=TEXT($AB$2*29,"mmmm")
AD4:AD14AD4=IF($AA4="xx","",IF($AA4<>$AE$2,$AG$4,IF($AA4=$AE$2,$AG$5)))


The second Mini Sheet must appear in a follow-up to this post as I received the message "Generated content exceeds the limit..."
Here then is the second Mini Sheet: Okay same message. An image will have to suffice.
 

Attachments

  • Sep2Dec2024.png
    Sep2Dec2024.png
    25.2 KB · Views: 6
Upvote 0
I am not sure how to do this, so here goes. I found the solution in case anyone wants to know what it is then the following Mini Sheet should help to clarify.
BogusSchedule2024_Chngs.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAE
2SepSepSepSepSepSepOctOctOctOctOctOctNovNovNovNovNovNovDecDecDecDecDecDecNovember 06, 202411October
3Wk1Wk2Wk3Wk4Wk5Wk6Wk1Wk2Wk3Wk4Wk5Wk6Wk1Wk2Wk3Wk4Wk5Wk6Wk1Wk2Wk3Wk4Wk5Wk62024November
4Action 0172828OctOctober 28, 2024Oct
5Action 0216279182866NovNovember 06, 2024Nov
6Action 0316279182877NovNovember 07, 2024Nov
7Action 0416279182866NovNovember 06, 2024Nov
8Action 0562488NovNovember 08, 2024Nov
9Action 06168182855NovNovember 05, 2024Nov
10Action 071818OctOctober 18, 2024Oct
11Action 081699OctOctober 09, 2024Oct
12Action 098182855NovNovember 05, 2024Nov
13Action 108182855NovNovember 05, 2024Nov
14Action 11xx  #N/A
Sheet1
Cell Formulas
RangeFormula
AA2AA2=TEXT($AD$3&" "&AA5&", "&$AA$3,"mmmm dd, yyyy")
AB2AB2=MONTH(AF3)
AD2AD2=TEXT(TODAY()-DAY(TODAY()),"mmmm")
AD3AD3=TEXT($AB$2*29,"mmmm")
AA4:AA14AA4=IFERROR(LOOKUP(2,1/(B4:Y4<>""),B4:Y4),"xx")
AB4:AB14AB4=IF(ISERROR(AE4),"",AE4)
AD4:AD14AD4=IF($AA4="xx","",TEXT($AB4&" "&$AA4&", "&$AA$3,"mmmm dd, yyyy"))
AE4:AE14AE4=XLOOKUP(AA4,B4:Y4,$B$2:$Y$2,0)
 
Upvote 0
If you did not want to repeat all those month headings or use helper columns as you have done, you could try these formulas.

24 11 07.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1
2SeptemberOctoberNovemberDecemberNovember 6, 202411October
31st2nd3rd4th5th6th1st2nd3rd4th5th6th1st2nd3rd4th5th6th1st2nd3rd4th5th6th2024November
4Action 0172828October 28, 2024
5Action 0216279182866November 06, 2024
6Action 0316279182877November 07, 2024
7Action 0416279182866November 06, 2024
8Action 0562488November 08, 2024
9Action 06168182855November 05, 2024
10Action 071818October 18, 2024
11Action 081699October 09, 2024
12Action 098182855November 05, 2024
13Action 108182855November 05, 2024
14Action 11xx 
Dates
Cell Formulas
RangeFormula
AA4:AA14AA4=IFNA(LOOKUP(99,B4:Y4),"xx")
AD4:AD14AD4=IFNA(LOOKUP("zz",B$2:INDEX(B$2:Y$2,LOOKUP(99,B4:Y4,COLUMN(B$2:Y$2)-COLUMN(B$2)+1)))&TEXT(AA4," 00\, ")&AA$3,"")
 
Upvote 0
If you did not want to repeat all those month headings or use helper columns as you have done, you could try these formulas.

24 11 07.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1
2SeptemberOctoberNovemberDecemberNovember 6, 202411October
31st2nd3rd4th5th6th1st2nd3rd4th5th6th1st2nd3rd4th5th6th1st2nd3rd4th5th6th2024November
4Action 0172828October 28, 2024
5Action 0216279182866November 06, 2024
6Action 0316279182877November 07, 2024
7Action 0416279182866November 06, 2024
8Action 0562488November 08, 2024
9Action 06168182855November 05, 2024
10Action 071818October 18, 2024
11Action 081699October 09, 2024
12Action 098182855November 05, 2024
13Action 108182855November 05, 2024
14Action 11xx 
Dates
Cell Formulas
RangeFormula
AA4:AA14AA4=IFNA(LOOKUP(99,B4:Y4),"xx")
AD4:AD14AD4=IFNA(LOOKUP("zz",B$2:INDEX(B$2:Y$2,LOOKUP(99,B4:Y4,COLUMN(B$2:Y$2)-COLUMN(B$2)+1)))&TEXT(AA4," 00\, ")&AA$3,"")
I will give these a try.
In the same file I have another problem. How to get the second to last value, or more specifically how to get the value previous to the last value in a row range.
For example in this Mini Sheet how to get the value 28 out of this row because it is the previous value to the last value 5 and then input this value 28 into a separate cell.
BogusSchedule2024_Chngs.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXY
9Action 0616818285
Sheet1
 
Upvote 0
Perfect, works very well. Thanks Peter_SSs
You're welcome. Thanks for the follow-up. :)

I have removed the 'Mark as solution' tick from post #6 as that is not a solution to the original thread question.
If an earlier post did answer that original question then you can mark that post as the solution to help future readers, otherwise don't mark any post.
 
Upvote 0
Although I like Post #'s 4 & 6, and have tested them as they work fine, I already instituted a solution as seen in Post #3 thus I won't change my spreadsheet to incorporate solutions from Post #'s 4 & 6 but did copy them into the spreasheet for future use.
 
Upvote 0
I did change the original worksheet to incorporate these changes. The first Mini Sheet I posted was a copy of this new Mini Sheet post with several month columns deleted. This new Mini Sheet shows all 6 months July to December. I only post here now to sgare my solution should anyone be interested.

ApartmentCleaningSchedule2024_Chngs.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASAT
18JulJulJulJulJulJulAugAugAugAugAugAugSepSepSepSepSepSepOctOctOctOctOctOctNovNovNovNovNovNovDecDecDecDecDecDecNovember 28, 202411October8
19Wk1Wk2Wk3Wk4Wk5Wk6Wk1Wk2Wk3Wk4Wk5Wk6Wk1Wk2Wk3Wk4Wk5Wk6Wk1Wk2Wk3Wk4Wk5Wk6Wk1Wk2Wk3Wk4Wk5Wk6Wk1Wk2Wk3Wk4Wk5Wk62024November11/8/2024
20Action 01772828OctOctober 28, 20247Oct
21Action 021816279182828OctOctober 28, 202418Oct
22Action 031816279182828OctOctober 28, 202418Oct
23Action 041816279182828OctOctober 28, 202418Oct
24Action 05662424OctOctober 24, 20246Oct
25Action 0618168182828OctOctober 28, 202418Oct
26Action 07 1818OctOctober 18, 2024 Oct
27Action 08161699OctOctober 09, 202416Oct
28Action 09288182855NovNovember 05, 202428Nov
29Action 10288182855NovNovember 05, 202428Nov
30Action 11 77NovNovember 07, 2024 Nov
Sheet1
Cell Formulas
RangeFormula
AO18AO18=TEXT($AR$19&" "&AO21&", "&$AO$19,"mmmm dd, yyyy")
AP18AP18=MONTH(AS19)
AR18AR18=TEXT(TODAY()-DAY(TODAY()),"mmmm")
AS18AS18=DAY(AS19)
AR19AR19=TEXT($AP$18*29,"mmmm")
AS19AS19=TODAY()
A20A20=$A$4
B20:B30B20=IFERROR(INDEX($D20:$AM20,AGGREGATE(14,6,COLUMN($D20:$AM20)-COLUMN(C20)/($D20:$AM20<>""),2)),"")
A21A21=$A$5
A22A22=$A$6
A23A23=$A$7
A24A24=$A$8
A25A25=$A$9
A26A26=$A$10
A27A27=$A$11
A28A28=$A$12
A29A29=$A$13
A30A30=$A$14
AO20:AO30AO20=IFERROR(LOOKUP(2,1/(D20:AM20<>""),D20:AM20),"xx")
AP20:AP30AP20=IF(ISERROR(AT20),"",AT20)
AR20:AR30AR20=IF($AO20="xx","",TEXT($AP20&" "&$AO20&", "&$AO$19,"mmmm dd, yyyy"))
AS20:AS30AS20=B20
AT20:AT30AT20=XLOOKUP(AO20,D20:AM20,$D$18:$AM$18,0)
 
Upvote 0
Solution

Forum statistics

Threads
1,223,578
Messages
6,173,167
Members
452,504
Latest member
frankkeith2233

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