I have a excel file with two sheets. Secon tab stored all previosu data and in the first tab I am adding new data every day. I need to comapre dates in column from 1st sheet and 2nd sheet and then copy from 1st tab only those lines where date is greater then in second tab (of course copy and paste data ti 2nd tab just after last row) .
What is more and most important for me I need to copy only data from 1st column from 1st tab not entire row.
Below code is almost perfect but at the end entire row is copying to the second tab but I need only data from 1st column,
Sub future()
Dim sh As Worksheet, lr As Long, rng As Range, sh2 As Worksheet, lr2 As Long
Set sh = Sheets(1) 'Edit sheet name
Set sh2 = Sheets(2) 'Edit Sheet name
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = sh.Range("A3:A" & lr)
For Each c In rng
If DateValue(c.Value) >= DateValue(Date) Then
lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row + 1
c.EntireRow.Copy sh2.Range("A" & lr2)
End If
Next
End Sub
I want to use Your Code but A bit modified. I need copy not entire row but only data from 1st column. I mean I have two sheets and in column L we have 'created on date'. I have to copy ID's from tab1 (column A) and past into tab 2 column A (into first free row) only those rows where data in column L tab 1 is newest then date in column L tab2.
What is more and most important for me I need to copy only data from 1st column from 1st tab not entire row.
Below code is almost perfect but at the end entire row is copying to the second tab but I need only data from 1st column,
Sub future()
Dim sh As Worksheet, lr As Long, rng As Range, sh2 As Worksheet, lr2 As Long
Set sh = Sheets(1) 'Edit sheet name
Set sh2 = Sheets(2) 'Edit Sheet name
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = sh.Range("A3:A" & lr)
For Each c In rng
If DateValue(c.Value) >= DateValue(Date) Then
lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row + 1
c.EntireRow.Copy sh2.Range("A" & lr2)
End If
Next
End Sub
I want to use Your Code but A bit modified. I need copy not entire row but only data from 1st column. I mean I have two sheets and in column L we have 'created on date'. I have to copy ID's from tab1 (column A) and past into tab 2 column A (into first free row) only those rows where data in column L tab 1 is newest then date in column L tab2.