Spreadsheet dates in a calendar layout?

stereosympathy

Board Regular
Joined
Nov 11, 2006
Messages
142
HI,

I have a sheet pasted below, I am wondering if it is possible to take data and have it automatically laid out in a calendar format. Say all the dates in column G could be sorted into a calendar with reference text from column E. Any help on this would be appreciated.
Unique Print Schedule.xls
ABCDEFGHIJKLM
9162125961239/4/2007JudsonJusdonRockets29/10/2007300UPSGNDApprovedNone1518-125WHHCGrommet25pcsONLY!!!!
10162555962149/5/2007MCASA1PhilipWelpSoccer29/10/2007200UPSGNDAwaitingAppNone1525-23WHHL
119/6/2007SuccessPromotionsSpringfieldCardinals39/11/20074800ADVISEApprovedNone1518-15WHHP
12162759/6/2007UNICH1NorthCarolinaFieldHockey29/11/20072006UPSGNDAwaitingAppNone1118-12DCARBLUE6SamplestoDonnyDonDon
13162789/6/2007WilsonNFLShield49/12/2007500UPSGNDApprovedNone1625WHMW
14SuccessPromotionsSpringfieldCardinals39/12/20075000ADVISEApprovedNone1518-15WHHP
1516215-A5961249/4/2007CustomTowelsUPS19/13/2007150UPSGNDApprovedNone1118-12WHHRHook&GrommetInsureShipment
16AguaExerciseWithAltitude19/13/2007150UPS2DayAwaitingAppNone1625-25WHHC
17163045874769/7/2007GREGREGCHSTigres29/14/200775UPSGNDApprovedNone1525-23-BKHLShipFromTeamSpiritTowels
18157505942668/6/2007GreenBayPackersForceProud2BLoud39/17/2007144,002UPSGNDApprovedNone1118-12WHHRNone
19157788/7/2007PPISportsU.S.Cellular/Wisconsin"W"39/18/200755,200ADVISEApprovedNone1118-12WHHRusesecondsforextra's
20157535936788/6/2007McArthurArizonaCardinals49/20/200767,006ODFLApprovedStrikeSent1218-13WHFI6postProToDon
21162049/4/2007PPISportsMichiganGoBlue19/20/20071016UPSGNDAwaitingAppNone1118-12PMS10910towelstoGregCannon6toDon
22162569/7/2007TimeWarnerBuffaloBills"Billieve59/26/200760036ODFLAwaitingAppNone1118-12WHHR36postprotoDonnyDon
238/31/2007AguaWreckEmTech?10/1/20071005UPSGNDAwaitingAppNone1518-125WHHC
248/28/2007AguaGoHogs310/1/20071005UPSGNDAwaitingAppNone1518-125WHHC
UpComingOrders
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
This is the general concept, the formatting is a little goofy. It is too time consuming for me to manually enter data into a calendar format but this is a production schedule and it would be nice to have this sheet lay this out automatically to give to each person in production to have a clear layout of what is due on what day. Is this even possible?
Unique Print Schedule.xls
ABCDEFG
1MondayTuesdayWednesdayThursdayFridaySaturdaySunday
23456789
3
410111213141516
5JudsonRockets300pc1518-125WHHC
617181920212223
7
824252627282930
9
Sheet1
 
Upvote 0
Dear stereosympathy
Try this VBA code. Note that the date format may have to be modified in a few places as I have dd/mm/yyyy format here. However, I think it would do the job for you. If anyone has better ways, I would be happy to learn.
You need two sheets, UpComingOrders and CalSheet. CalSheet is a blank sheet.
Michael :biggrin:

Code:
Sub CreateCalendar()
Dim strCalMonth, strYear, varFirstOfMonth As String
Dim strDateTest, strDate, strWotsOn As String

Dim varCalMonth, varDayFirstOfMonth As Integer

Dim lngModYear, varDaysInMonth, lngRow, vday, lngdow, lngdowCol, lngInputRow As Long
Dim lngDay, lngDayVal, lngDayCol, lngDayRow As Long

varCalMonth = Month(Now)
strYear = "2007"
varFirstOfMonth = "01/" & varCalMonth & "/" & strYear ' this is set up in Aus date format dd/mm/yyyy
strCalMonth = "September"
varDayFirstOfMonth = Weekday(varFirstOfMonth, 2) ' the 2 means that we start with Monday as first day of week

' First build the calendar for the month

lngModYear = strYear Mod 4
Select Case varCalMonth
    Case 2
        If lngModYear = 0 Then
            varDaysInMonth = 29
        Else
            varDaysInMonth = 28
        End If
        
    Case 4, 6, 9, 11
        varDaysInMonth = 30
    Case Else
        varDaysInMonth = 31
End Select

Sheets("CalSheet").Select
Range("CalendarArea").ClearContents

Cells(1, 3).Value = strCalMonth
Cells(3, 1).Value = "Monday"
Cells(3, 2).Value = "Tuesday"
Cells(3, 3).Value = "Wednesday"
Cells(3, 4).Value = "Thursday"
Cells(3, 5).Value = "Friday"
Cells(3, 6).Value = "Saturday"
Cells(3, 7).Value = "Sunday"

For vday = 1 To varDaysInMonth
'start of month is day x
' each day builds on that modulo 7
    
    lngdow = varDayFirstOfMonth + vday - 1
    lngdowCol = lngdow Mod 7
    
    If lngdowCol = 0 Then lngdowCol = 7
    lngRow = Int((lngdow - 1) / 7)
    Cells(2 * lngRow + 4, lngdowCol).Value = vday
   
Next

' Now fill in the daily sheets
Sheets("UpComingOrders").Select
lngInputRow = 2
lngDayRow = 0
Cells(lngInputRow, 7).Select
strDateTest = "00/00/00"

While ActiveCell <> "" And Month(ActiveCell) = varCalMonth
    strDate = ActiveCell
    lngDay = Day(strDate)
    lngDayVal = varDayFirstOfMonth + lngDay - 1
    lngDayCol = lngDayVal Mod 7
    
    If lngDayCol = 0 Then lngDayCol = 7
        
    lngDayRow = Int(lngDayVal / 7)
    
    If ActiveCell <> strDateTest Then
        strWotsOn = ActiveCell.Offset(0, -2)
    Else
        strWotsOn = strWotsOn & vbCrLf & ActiveCell.Offset(0, -2)
    End If
    
    Sheets("CalSheet").Cells(2 * lngDayRow + 5, lngDayCol).Value = strWotsOn
    
    strDateTest = ActiveCell
    lngInputRow = lngInputRow + 1
    Cells(lngInputRow, 7).Select

Wend

End Sub
 
Upvote 0
My code will work on the sheet as shown in the original Post. To make it applicable across all months, it needs a couple on modications.
The following code will work when the current month is October. I need to think about how to fix the front end so that you can run the cose for any month of your choice.
Code:
Sub CreateCalendar()
Dim strCalMonth, strYear, varFirstOfMonth As String
Dim strDateTest, strDate, strWotsOn As String

Dim varCalMonth, varDayFirstOfMonth As Integer

Dim lngModYear, varDaysInMonth, lngRow, vday, lngdow, lngdowCol, lngInputRow As Long
Dim lngDay, lngDayVal, lngDayCol, lngDayRow As Long

' This needs to be revised to become universal for all months

varCalMonth = Month(Now)

strYear = "2007"
varFirstOfMonth = "01/" & varCalMonth & "/" & strYear ' this is set up in Aus date format dd/mm/yyyy
strCalMonth = "October"
varDayFirstOfMonth = Weekday(varFirstOfMonth, 2) ' the 2 means that we start with Monday as first day of week

' First build the calendar for the month

lngModYear = strYear Mod 4
Select Case varCalMonth
    Case 2
        If lngModYear = 0 Then
            varDaysInMonth = 29
        Else
            varDaysInMonth = 28
        End If
        
    Case 4, 6, 9, 11
        varDaysInMonth = 30
    Case Else
        varDaysInMonth = 31
End Select

Sheets("CalSheet").Select
Range("CalendarArea").ClearContents

Cells(1, 3).Value = strCalMonth
Cells(3, 1).Value = "Monday"
Cells(3, 2).Value = "Tuesday"
Cells(3, 3).Value = "Wednesday"
Cells(3, 4).Value = "Thursday"
Cells(3, 5).Value = "Friday"
Cells(3, 6).Value = "Saturday"
Cells(3, 7).Value = "Sunday"

For vday = 1 To varDaysInMonth
'start of month is day x
' each day builds on that modulo 7
    
    lngdow = varDayFirstOfMonth + vday - 1
    lngdowCol = lngdow Mod 7
    
    If lngdowCol = 0 Then lngdowCol = 7
    lngRow = Int((lngdow - 1) / 7)
    Cells(2 * lngRow + 4, lngdowCol).Value = vday
   
Next

' Now fill in the daily sheets
Sheets("UpComingOrders").Select
lngInputRow = 2
lngDayRow = 0
Cells(lngInputRow, 7).Select
strDateTest = "00/00/00"

While ActiveCell <> ""
    If Month(ActiveCell) = varCalMonth Then
        strDate = ActiveCell
        lngDay = Day(strDate)
        lngDayVal = varDayFirstOfMonth + lngDay - 1
        lngDayCol = lngDayVal Mod 7
    
        If lngDayCol = 0 Then lngDayCol = 7
        
        lngDayRow = Int(lngDayVal / 7)
    
        If ActiveCell <> strDateTest Then
            strWotsOn = ActiveCell.Offset(0, -2)
        Else
            strWotsOn = strWotsOn & vbCrLf & ActiveCell.Offset(0, -2)
        End If
    
        Sheets("CalSheet").Cells(2 * lngDayRow + 5, lngDayCol).Value = strWotsOn
    End If
    
    strDateTest = ActiveCell
    lngInputRow = lngInputRow + 1
    Cells(lngInputRow, 7).Select

Wend

End Sub
 
Upvote 0
Triff,

This code looks pretty impressive. Which sheet should I put this on and how do I get it to "Calendar"? I have it in UpComingOrders but nothing happens. Thanks a lot for the help so far, thats a lot of coding!!
 
Upvote 0
stereosympathy
Open VBA with alt F11. In the project for your workbook insert a new module (Insert Module) and paste the code into the module. From UpComingOrders run the macro (doesn't matter which sheet you are in actually) - Tools Macro Macros (CreateCalendar) Run.
Michael
 
Upvote 0
Michael,

I have the macro running and it lays out a calendar in CalSheet which is awesome but it doesn't diplay anything from UpComingOrders sheet in the calendar. Do I need to format the cells a certain way to get them to display?
 
Upvote 0
The macro is working well for me.
I think it may not be reading your input data as being for September. The way it is set up, column G should be in DATE format.
Also check that the Calendar in CalSheet is actually for September commencing on a Saturday and with 30 days as it may think that it is the first Month of the year(ie 1/9 not 9/1).
If you like you can either step through the macro or insert a couple of msgbox steps to determine what is happening.
cheers
Michael :)
 
Upvote 0
You are totally right! It is displaying a calendar for 1/9. I'm sorry to keep asking you questions but how do I change that so it is set to 9/1, not 1/9?
 
Upvote 0

Forum statistics

Threads
1,214,968
Messages
6,122,509
Members
449,089
Latest member
RandomExceller01

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