[Bold]
Objective: Populate the last column, Col 18, on worksheet "ws3" with the date that the updated record(s) was/were appended to worksheet, ws3
[/Bold]
I am using MS Excel 2016 and have data within two worksheets - "ws1" and "ws3."
ws1 is refreshed (from a CSV file on the network drive) upon opening the workbook and displays the updated data with the "AccountNo." field in column A.
ws3 contains the same columns and an additonal column that I added that is named "DateThatRecordWasAppended."
There are 17 columns of data on worksheet ws1. However, for worksheet ws3, I have 18 columns.
The code below successfully appends the updated data from ws1 to ws3 - populating columns 1 through 17.
[Bold]
But, I am not able to populate column 18 on worksheet "ws3" with the date and time that the record was appended.
[/Bold]
Currently reviewing but thought that some immediate insight may be necessary due to spending over an hour to resolve.
Any insight as to the needed modifications to accomplish objective is appreciated.
Conceptualizing a bit - maybe the code to actually populate the 18th column should be after all of the columns have
been copied for a particular row.
Or, maybe a nested FOR statement whereby the data is copied by row initially...
The review continues...
Code:
Sub TestAppend()
Dim c As Range, f As Range
Dim ws1, ws3
Set ws1 = Worksheets("Data_1")
Set ws3 = Worksheets("Data_3")
For Each c In ws1.Range(ws1.Range("A1"), ws1.Cells(Rows.Count, 1).End(xlUp)).Cells
Set f = ws3.Range(ws3.Range("A1"), _
ws3.Cells(Rows.Count, 1).End(xlUp)).Find( _
What:=c.Value, lookat:=xlWhole)
If f Is Nothing Then
ws3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Resize(1, 17).Value = _
c.Resize(1, 17).Value
'ws3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Resize(1, 18).Value = Now() 'Iter 2 - Error
End If
Next c
End Sub