Take data with start and end data and add it to my excell callender area

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,201
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

Ok so I have a sheet called "Cal" that is made up of Event Names Down Column H and Dates from 1st April 2018 to 1st April 2021 along Row 10 (Range J10:APM10)

I have another sheet called "Data"

Down Column D is the Event Name, Column E is start date, Column F is end date.

so what I need is a macro to fill in my calendar in sheet "Cal" with the appointments in sheet Data.

So I need the macro to look at each row in Column D of Data and find that project name in "Cal" Column H
then look at the start date and end date and insert the word "Out" into each cell for that appointment then move on to the next etc.

So basicly take the appointment in sheet "Data" and add them to my "Cal" sheet using the name and the dates.

any ideas how I could do this?

Thanks

Tony
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hey Tony,

Give this a bash:

Code:
Public Sub FillCalendar()

Dim dataSheet As Worksheet
Dim calSheet As Worksheet
Dim lastRow As Long
Dim thisRow As Long
Dim foundRow As Variant
Dim startDate As Date
Dim endDate As Date
Dim thisDate As Date
Dim firstDate As Date

Set dataSheet = Sheets("Data")
lastRow = dataSheet.Cells(dataSheet.Rows.Count, "D").End(xlUp).Row
Set calSheet = Sheets("Cal")
firstDate = calSheet.Range("J10").Value

For thisRow = 1 To lastRow
    foundRow = Application.Match(dataSheet.Cells(thisRow, "D").Value, calSheet.Range("H:H"), 0)
    If Not IsError(foundRow) Then
        startDate = dataSheet.Cells(thisRow, "E").Value
        endDate = dataSheet.Cells(thisRow, "F").Value
        If startDate >= firstDate And endDate >= startDate Then
            For thisDate = startDate To endDate
                calSheet.Cells(foundRow, thisDate - firstDate + 10).Value = "Out"
            Next thisDate
        End If
    End If
Next thisRow

End Sub

WBD
 
Upvote 0

Forum statistics

Threads
1,215,750
Messages
6,126,663
Members
449,326
Latest member
asp123

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