Dear all,
I have a Workbook called Data.xlsx with sheet1 containing data in columns A to G. This data is growing daily by the operators, meaning that everyday new rows are added.
What I would like, is to take ONLY the new data added since the last time and copy it to another Workbook called ALLData.xlsm in the sheet "DailyData"
In column A operators are entering a unique value that is never repeated. So, I would like a macro that takes the last value entered in column A in the workbook "ALLData.xlsm" and goes to the Workbook Data.xls, search for this last value and copy the next new rows from column A to G that were recently added and paste them to ALLData.xlsm
I know it could be easily done copying and pasting every time the range A1:G999999, but I dont want to always overwrite all the data, I just want to add the new rows as per the last time I updated my file.
Can somebody help me with this issue please?
Thanks you all in advance!
PD: My actual code is such a mess because I'm completely lost... it also should copy the rows containing "X" in the column H... but this could be omitted...
I have a Workbook called Data.xlsx with sheet1 containing data in columns A to G. This data is growing daily by the operators, meaning that everyday new rows are added.
What I would like, is to take ONLY the new data added since the last time and copy it to another Workbook called ALLData.xlsm in the sheet "DailyData"
In column A operators are entering a unique value that is never repeated. So, I would like a macro that takes the last value entered in column A in the workbook "ALLData.xlsm" and goes to the Workbook Data.xls, search for this last value and copy the next new rows from column A to G that were recently added and paste them to ALLData.xlsm
I know it could be easily done copying and pasting every time the range A1:G999999, but I dont want to always overwrite all the data, I just want to add the new rows as per the last time I updated my file.
Can somebody help me with this issue please?
Thanks you all in advance!
PD: My actual code is such a mess because I'm completely lost... it also should copy the rows containing "X" in the column H... but this could be omitted...
VBA Code:
Sub transDATA()
Dim StRo As Integer, T As Integer, Ro2 As Integer, Lr As Integer
Application.ScreenUpdating = False
Application.EnableEvents = False
Workbooks("Data.xlsx").Activate
Worksheets("sheet1").Activate
With Sheets("sheet1")
M = Workbooks("ALLDATA.xlsm").Worksheets("DailyData").UsedRange.Rows.Count
If Workbooks("ALLDATA.xlsm").Worksheets("DailyData").UsedRange.Rows.Count = 1 Then
.Range("A1:G1").Copy
Workbooks("ALLDATA.xlsm").Worksheets("DailyData").Range("A1")
StRo = .Range("H:H").Find("X").Row
Lr = 1
Else
Lr = Workbooks("ALLDATA.xlsm").Worksheets("DailyData").Range("A" & Rows.Count).End(xlUp).Row
StRo = .Range("A:A").Find(Workbooks("ALLDATA.xlsm").Worksheets("DailyData").Range("A" & Lr)).Row + 1
End If
For T = StRo To .Range("A" & Rows.Count).End(xlUp).Row
If .Range("H" & T) = "X" Then
Ro2 = Ro2 + 1
Workbooks("ALLDATA.xlsm").Worksheets("DailyData").Range("A" & Lr + Ro2 & ":G" & Lr + Ro2).Value = .Range("A" & T & ":G" & T).Value
End If
Next T
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
Workbooks("ALLDATA.xlsm").Worksheets("DailyData").Activate
End Sub