Hi everyone,
I'm trying to create a for loop that iterates through rows of a data located on "Master Publisher Content." I am trying to code it so if data in column G is less than the user-specified start date, within cell "C2" in the "Enter Info" worksheet, then the cell will be changed to the dates in cell C2.
For example, if my start date in C2 is May 1st and there is data in column G, (G4 e.g) of the Publisher Content tab that is April 15th, I want to change the cell in G4 from April 15th to May 1st.
I've played around with the code quite a bit, there are some issues with an object not being defined within the for loop. Could someone explain the logic behind defining objects?
Thank you so much in advance!!! I appreciate it
I'm trying to create a for loop that iterates through rows of a data located on "Master Publisher Content." I am trying to code it so if data in column G is less than the user-specified start date, within cell "C2" in the "Enter Info" worksheet, then the cell will be changed to the dates in cell C2.
For example, if my start date in C2 is May 1st and there is data in column G, (G4 e.g) of the Publisher Content tab that is April 15th, I want to change the cell in G4 from April 15th to May 1st.
I've played around with the code quite a bit, there are some issues with an object not being defined within the for loop. Could someone explain the logic behind defining objects?
Thank you so much in advance!!! I appreciate it
Code:
Sub adjust_dates()
Dim Ctr As Long
Dim ctr1 As Long
Dim StartDate As Date
Dim wksheet As Worksheet
Set wksheet = ThisWorkbook.Worksheets("Enter Info")
Ctr = Range("G3", Range("G3").End(xlDown)).Count
StartDate = ThisWorkbook.Worksheets("Enter Info").Range("C2")
For i = 3 To Ctr
If Cells(i, 7) < StartDate Then
With wksheet
ThisWorkbook.Worksheets("Enter Info").Range("C2").Select.Copy
wksheet.Cells(i, 7).Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
End With
End If
Next i
End Sub