Confusion with data validation (list)

quemuenchatocha

Board Regular
Joined
Aug 4, 2021
Messages
50
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello cordial greetings

I am new, I hope I am not making a mistake at the time of posting.

I am a bit confused, I need to perform a data validation in cell C7, so that the days correspond to the month set in cell C6 and the year found in cell C8. The data is recorded in the DATA tab; I have tried INDEX + MATCH functions, as well as OFFSET, but none of them meet what I require (I think I am making a lot of mistakes). Can you please help me with a solution or give me a hint on how to find a formula that does what is required.

Exactly, what I am trying to do is that when selecting for example the month of January (C6) of the year 2018 (C8), in the drop-down list of the cell C7 only the 31 days corresponding to the specified month appear. That is to say, if I select February, 28 days will appear and not 30 or 31 days, with the exception of if it is a leap year, in which case, 29 days should appear for the month of February.

To do this, I want to select the data corresponding to Year (A5:A45388), Name (C5:C45388) and Day (D5:D45388), which are located in the "Data" tab, and depending on the year selected in the Sheet 1 tab (C8) and month (C6), bring me the respective days for that date.

Since January, March, May, July, August, October and December have 31 days, if I select any of these months, regardless of the year, those 31 days should appear in the drop-down list located in cell C7, and not 30 or 28 days.

The same would apply if you select the months of April, June, September and November, in which case the 30 days should appear in the drop-down list in cell C7 and not 31 or 28 (29 if February is part of a leap year).

Example_Weather.xlsx
ABCDEFG
1
2
3
4
5
6MonthDecemberHigh Temp5050
7Day25Low Temp27
8Year2019Precip0
9Snow0
10
11
Hoja1
Cell Formulas
RangeFormula
G6G6=INDEX(High,MATCH($C$8&$C$6&$C$7,Year&Name&Day,0))
F6F6=IF(INDEX(High,MATCH($C$8&$C$6&$C$7,Year&Name&Day,0))<0,"Not available",INDEX(High,MATCH($C$8&$C$6&$C$7,Year&Name&Day,0)))
F7F7=IF(INDEX(Low,MATCH($C$8&$C$6&$C$7,Year&Name&Day,0))<0,"Not available",INDEX(Low,MATCH($C$8&$C$6&$C$7,Year&Name&Day,0)))
F8F8=IF(INDEX(Precip,MATCH($C$8&$C$6&$C$7,Year&Name&Day,0))<0,"Not available",INDEX(Precip,MATCH($C$8&$C$6&$C$7,Year&Name&Day,0)))
F9F9=IF(INDEX(Snow,MATCH($C$8&$C$6&$C$7,Year&Name&Day,0))<0,"Not available",INDEX(Snow,MATCH($C$8&$C$6&$C$7,Year&Name&Day,0)))
Named Ranges
NameRefers ToCells
Day=Data!$D$5:$D$45388F6:F9, G6
High=Data!$E$5:$E$45388F6:G6
Low=Data!$F$5:$F$45388F7
Name=Data!$C$5:$C$45388F6:F9, G6
Precip=Data!$G$5:$G$45388F8
Snow=Data!$H$5:$H$45388F9
Year=Data!$A$5:$A$45388F6:F9, G6
Cells with Data Validation
CellAllowCriteria
C6List=Data!$M$5:$M$16
C7List=Data!$Q$5:$Q$35
C8List=Data!$K$5:$K$128


Example_Weather.xlsx
ABCDEFGHIJKLMNOPQR
1Historical Weather Lookup
2Boulder, Colorado (USA)Data is at:Boulder, Colorado Climate and Weather Data: NOAA Physical Sciences Laboratory
3
4YearMonthNameDayHighLowPrecipSnowYearMonthNameDay
518971January1-998-998-998-99818971JanuaryJanuaryJanuary1
618971January2-998-998-998-99818982FebruaryFebruaryJanuary2
718971January3-998-998-998-99818993MarchMarchJanuary3
818971January4-998-998-998-99819004AprilAprilJanuary4
918971January5-998-998-998-99819015MayMayJanuary5
1018971January6-998-998-998-99819026JuneJuneJanuary6
1118971January7-998-998-998-99819037JulyJulyJanuary7
1218971January8-998-998-998-99819048AugustAugustJanuary8
1318971January9-998-998-998-99819059SeptemberSeptemberJanuary9
1418971January10-998-998-998-998190610OctoberOctoberJanuary10
1518971January11-998-998-998-998190711NovemberNovemberJanuary11
1618971January12-998-998-998-998190812DecemberDecemberJanuary12
1718971January13-998-998-998-998190913
1818971January14-998-998-998-998191014
1918971January15-998-998-998-998191115
2018971January16-998-998-998-998191216
2118971January17-998-998-998-998191317
Data
Cell Formulas
RangeFormula
K5:K128,L5:L16K5=UNIQUE(A5:A45388,FALSE)
M5:M16,C5:C21M5=IF(L5=1,"January",IF(L5=2,"February",IF(L5=3,"March",IF(L5=4,"April",IF(L5=5,"May",IF(L5=6,"June",IF(L5=7,"July",IF(L5=8,"August",IF(L5=9,"September",IF(L5=10,"October",IF(L5=11,"November","December")))))))))))
N5:N16N5=IFS($L5,$M5,$L6,$M6,$L7,$M7,$L8,$M8,$L9,$M9,$L10,$M10,$L11,$M11,$L12,$M12,$L13,$M13,$L14,$M14,$L15,$M15,$L16,$M16)
O5:O16O5=IFS(1,$M$5,2,$M$6,3,$M$7,4,$M$8,5,$M$9,6,$M$10,7,$M$11,8,$M$12,9,$M$13,10,$M$14,11,$M$15,12,$M$16)
Dynamic array formulas.
Named Ranges
NameRefers ToCells
Month=Data!$B$5:$B$45388L5, C5
Year=Data!$A$5:$A$45388K5


Thank you very much for your valuable attention.

PS: I have assigned range names to the table found in the DATA tab from the values in the top row (column header) and I am using Excel 365.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi and welcome to MrExcel,

Kudos for providing enough information to help you, well done!
The solution is to work with a dynamic array which depends on the excel version you're using.
As you mentioned the version is Excel365 so the first option would be good for you.

See if this helps:
Book1((Unsaved-309027512575542192)).xlsb
BCDEFGHIJ
5
6februari
711
8201922
933
1044
1155
1266
1377
1488
1599
161010
171111
181212
191313
201414
211515
221616
231717
241818
251919
262020
272121
282222
292323
302424
312525
322626
332727
342828
35
Sheet1
Cell Formulas
RangeFormula
F7:F34F7=SEQUENCE(DATE(C8,MONTH(C6&1)+1,1)-DATE(C8,MONTH(C6&1),1))
I7:I34I7=ROW(INDIRECT("1:"&DATE(C8,MONTH(C6&1)+1,1)-DATE(C8,MONTH(C6&1),1)))
Dynamic array formulas.
Cells with Data Validation
CellAllowCriteria
C7List=$F$7#
 
Upvote 0
Solution
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Data validation (list), confusion.
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Dear @jorismoerings thank you very much for your valuable information, you got me out of a problem that I could not find a solution. your two contributions work perfectly and is exactly what I needed, a big hug. I apologize, I don't know if I should leave you points or mark the answer as the solution, I'm new to this and so far I'm just learning how the forum works.
Again thank you very much!
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,748
Members
448,989
Latest member
mariah3

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