Import data from sheet into calendar

squirrellydw

Board Regular
Joined
Apr 2, 2015
Messages
105
Office Version
  1. 365
Platform
  1. Windows
I would like to be able to import some of the info in the screenshot into the calendar below. The calendar is found in excel, and can be found by typing in Calendar, it's called "Any Year one-month calendar1"

I would like to be able to import the last 3 columns into the correct date on the calendar but I wanna be able to pick what gets imported. For example only Seats 100 or more.

So April 1st, would list
DFW-190-0519
ATL-110-0605
CLT-128-0616 etc.

Is there an easy way I can do this? You guys have helped me in the past and I hope you can do it one more time. I can copy the data onto another tab of the calendar if that make it easier. I'm just looking for an automated way to do this.

Thanks

Screenshot 2025-03-12 163958.png
Cal.png
 
Something like this,

Please note, Your calendar range seems different from my calendar

Assuming your data is in Sheet named "Data", Calender is in Sheet named "Calender"
Book2
ABCDE
1DateMkt AIDestSeatsDep Time
2Apr 1, 2025AACLT76500
3Apr 1, 2025AADFW190519
4Apr 1, 2025AABOS50600
5Apr 1, 2025DLATL110605
6Apr 1, 2025UAIAD50605
7Apr 1, 2025AACLT128616
8Apr 1, 2025UAORD166630
9Apr 1, 2025AAPHL50642
10Apr 1, 2025AAORD50741
11Apr 1, 2025AACLT50830
12Apr 1, 2025UAIAD501015
13Apr 1, 2025G4PGD1801036
14Apr 1, 2025UAORD501052
15Apr 1, 2025AAORD501058
16Apr 1, 2025G4SRQ1801154
17Apr 1, 2025AACLT501157
18Apr 1, 2025AAPHL501200
19Apr 1, 2025DLATL1101300
20Apr 1, 2025AACLT761334
21Apr 1, 2025UAIAD501430
22Apr 1, 2025F9MCO1861512
23Apr 1, 2025AACLT501537
Data

I enabled the "Show Comment" option since the list is long exceeding the calender date box. If you want, you can modify to "Autofit" option.
1741824436335.png


Please modify the code according to your data structure
VBA Code:
Sub ImportAndUpdateCalendar()
    Dim wsData As Worksheet, wsCalendar As Worksheet
    Dim lastRow As Long, i As Long
    Dim dateCell As Range
    Dim seatCount As Integer
    Dim eventCode As String, eventTime As String
    Dim eventDate As Date
    Dim eventDetails As String
    Dim calendarRange As Range
    Dim tooltipText As String
    
    Set wsData = ThisWorkbook.Sheets("Data") ' Your event data sheet
    Set wsCalendar = ThisWorkbook.Sheets("Calendar") ' Your calendar sheet
    
    lastRow = wsData.Cells(wsData.Rows.Count, 1).End(xlUp).Row
    
    Set calendarRange = wsCalendar.Range("A7:M36") ' Modify
        
    For i = 2 To lastRow
        eventDate = wsData.Cells(i, 1).Value
        eventCode = wsData.Cells(i, 3).Value
        seatCount = wsData.Cells(i, 4).Value
        eventTime = wsData.Cells(i, 5).Value
        
        eventDetails = eventCode & " - " & seatCount & " seats - " & eventTime
        
        If seatCount >= 100 Then
            For Each dateCell In calendarRange
                If IsDate(dateCell.Value) And dateCell.Value = eventDate Then
                    If Not dateCell.Comment Is Nothing Then
                        tooltipText = dateCell.Comment.Text & vbNewLine & eventDetails
                        dateCell.Comment.Text Text:=tooltipText
                    Else
                        
                        dateCell.AddComment Text:=eventDetails
                        dateCell.Comment.Visible = False
                    End If
                    Exit For
                End If
            Next dateCell
        End If
    Next i
        
End Sub
 
Upvote 0
That’s close but the show comment part won’t work because I have to print this out. How do I enable the auto fit option?
 
Upvote 0
I would like to be able to import some of the info in the screenshot into the calendar below. The calendar is found in excel, and can be found by typing in Calendar, it's called "Any Year one-month calendar1"

I would like to be able to import the last 3 columns into the correct date on the calendar but I wanna be able to pick what gets imported. For example only Seats 100 or more.

So April 1st, would list
DFW-190-0519
ATL-110-0605
CLT-128-0616 etc.

Is there an easy way I can do this? You guys have helped me in the past and I hope you can do it one more time. I can copy the data onto another tab of the calendar if that make it easier. I'm just looking for an automated way to do this.

Thanks

View attachment 123218View attachment 123219
In the Calendar that I have, the space below each day number is just one cell. See image attached.

Is this the case with yours?

If one date cell has numerous entries do you want just that row to autofit or do you want the each row on the calendar to resize to match?

What is the expected maximum number of flights per day?

How do you change the year?
 

Attachments

  • Date.png
    Date.png
    10.1 KB · Views: 3
Upvote 0
In the Calendar that I have, the space below each day number is just one cell. See image attached.

Is this the case with yours? YES

If one date cell has numerous entries do you want just that row to autofit or do you want the each row on the calendar to resize to match? Just that ROW

What is the expected maximum number of flights per day? It changes monthly so can't really give you a good answer

How do you change the year? On mine I just change the Year at the top
Thank for the help, really appreciate it
 
Upvote 0

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