How can I edit this macro so it adds a line if date is aready used?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I nice complicated one this time.
I'll try explain the best I can, please ask if you need anything clarified.
I have a macro that goes down my calendar sheet and adds in the dates of all my apointments
The problem is that if I already have an appointment that day it gets overwritten.
so I want to edit it if I can to Add a new line if the date is already in use, but only if it needs to.
or example it might add an appointment for 12/04/19 then the next appointment is for 07/06/19 then the next 12/04/19 again, so it adds a new line and inputs the date below,
then carries on inserting dates into the original row but it get a date for 07/06/19, another conflict, but we already added a row so this time we don't need it add just add the date in the second row.

hope that makes sense, think of it like you where writing in a calendar if there's nothing in that date you type in the first row if there is you type in the next row down

Heres the code I use at the moment,
any help would be great
thanks

Tony


Sub Insert_Project_Deadline_Dates()

firstDate = Sheets("Project Deadlines").Range("S10").Value
Lastrow = Sheets("Project Deadlines Raw").Cells(Rows.Count, "A").End(xlUp).Row
For thisRow = 2 To Lastrow
foundRow = Application.Match(Sheets("Project Deadlines Raw").Cells(thisRow, "A").Value, Sheets("Project Deadlines").Range("D:D"), 0)
Pref = Sheets("Project Deadlines Raw").Cells(thisRow, "D")

If Not IsError(thisRow) Then
thisDate = Sheets("Project Deadlines Raw").Cells(thisRow, "C").Value
Sheets("Project Deadlines").Cells(foundRow, thisDate - firstDate + 19).Value = Pref



End If
Next thisRow



End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,214,375
Messages
6,119,165
Members
448,870
Latest member
max_pedreira

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