I'm creating a calendar of months. The user can select a year for the month they want. When a user selects to create a month, I want to select all the weekdays in that month and give it a named range. How can I select a range of cells for a selected month and year and give it a named range?
Here is the recorded macro (for Jan 2016), but I'm not sure how to create this programmatically. I cannot reuse it because what if the user picks a different month or year, then I won't know which row columns contain weekdays.
range( _
"C9:D9,E9:F9,G9:H9,I9:J9,K9:L9,C11:D11,E11:F11,G11:H11,I11:J11,K11:L11,C13:D13,E13:F13,G13:H13,I13:J13,K13:L13,C15:D15,E15:F15,G15:H15,I15:J15,K15:L15,C17:D17,E17:F17" _
).Select
range("E17").Activate
ActiveWorkbook.Names.Add Name:="Test", RefersToR1C1:= _
"=PTO!R9C3,PTO!R9C5,PTO!R9C7,PTO!R9C9,PTO!R9C11,PTO!R11C3,PTO!R11C5,PTO!R11C7,PTO!R11C9,PTO!R11C11,PTO!R13C3,PTO!R13C5,PTO!R13C7,PTO!R13C9,PTO!R13C11,PTO!R15C3,PTO!R15C5,PTO!R15C7,PTO!R15C9,PTO!R15C11,PTO!R17C3,PTO!R17C5"
----My Code Example----
For x = 1 to 42
' Determine where the 1st day falls
' Is it a weekday? Add my coordinates to an array so I can create a named range later.
Next x
CreateNamedRange(weekdayArray)
