Hello,
I have a vba script that copies entire rows that contain certain words from sheets(1) and paste the rows onto sheets(2).
Nothing is ever deleted on either sheets so both sheets are updated at the end of the last row.
Being that sheets(1) is the main sheet manually updated on a daily basis, data is never deleted, but I don't want to copy the same information that has already been previously copied and paste to sheet(2) again when I run the macro (which is what happens).
Can someone help with an addition to the code below that will skip all of the previously copied data?
I would suggest that maybe we use the last full row on sheets(2) and find that row on sheets(1) and then have my macro to start one row after that on sheets(1). (Basically the last row on sheets(2) represents the last row previously checked.)
Thanks in advance for all of your help.
I have a vba script that copies entire rows that contain certain words from sheets(1) and paste the rows onto sheets(2).
Nothing is ever deleted on either sheets so both sheets are updated at the end of the last row.
Being that sheets(1) is the main sheet manually updated on a daily basis, data is never deleted, but I don't want to copy the same information that has already been previously copied and paste to sheet(2) again when I run the macro (which is what happens).
Can someone help with an addition to the code below that will skip all of the previously copied data?
I would suggest that maybe we use the last full row on sheets(2) and find that row on sheets(1) and then have my macro to start one row after that on sheets(1). (Basically the last row on sheets(2) represents the last row previously checked.)
Code:
Sub SurveyMove()
Dim strArray As Variant
Dim wsSource As Worksheet
Dim wsDest As Worksheet
Dim NoRows As Long
Dim DestNoRows As Long
Dim I As Long
Dim J As Integer
Dim rngCells As Range
Dim rngFind As Range
Dim Found As Boolean
strArray = Array("Error", "Critical Error", "Severe Error")
Set wsSource = Sheets(1)
NoRows = wsSource.Range("A65536").End(xlUp).Row
Set wsDest = Sheets(2)
DestNoRows = wsDest.Range("A65536").End(xlUp).Row
For I = 1 To NoRows
Set rngCells = wsSource.Range("A" & I & ":H" & I)
Found = False
For J = 0 To UBound(strArray)
Found = Found Or Not (rngCells.Find(strArray(J)) Is Nothing)
Next J
If Found Then
rngCells.EntireRow.Copy wsDest.Range("A" & DestNoRows)
DestNoRows = DestNoRows + 1
End If
Next I
Columns("A:H").EntireColumn.AutoFit
End Sub
Thanks in advance for all of your help.
Last edited: