Compare data, and if different, copy to another worksheet

  • Thread starter Thread starter bugsyb
  • Start date Start date
B

bugsyb

I've been unable to find what I need by searching other posts, but I'm
hopeful someone can help me. We have a simple worksheet for users to enter
run time and downtime data for equipment on different production lines. The
data is entered in cells A5:H5 and then there is code to move it to the data
table (which is autofiltered) beginning in row 9 of the same sheet.

The code to move the data entry works fine, but I need to add to it. The
users would like to compare A9:D9 with A10:D10 and if different, copy and
paste A9:H9 to A9:H9 in a different worksheet. Column C is a date, the other
columns are formatted as general. The comparison will not change as new data
is always pasted into row 9, one row at a time.

If more info is needed, let me know. Any help is very much appreciated.
 
You will need to change the sheet references for sh and sh2 to your actual
sheet names.

Dim sh As Worksheet, sh2 As Worksheet,i As Long
Set sh = ActiveSheet
Set sh2 = Worksheets("Sheet2")

For i = 1 To 4
If sh.Cells(9, i) <> sh.Cells(10, i) Then
sh.Range("A9:H9").Copy sh2.Range("A9:H9")
Exit For
End If
Next

Untested but should work.
 
It worked perfectly! Thank you so much!

bugsyb

JLGWhiz said:
You will need to change the sheet references for sh and sh2 to your actual
sheet names.

Dim sh As Worksheet, sh2 As Worksheet,i As Long
Set sh = ActiveSheet
Set sh2 = Worksheets("Sheet2")

For i = 1 To 4
If sh.Cells(9, i) <> sh.Cells(10, i) Then
sh.Range("A9:H9").Copy sh2.Range("A9:H9")
Exit For
End If
Next

Untested but should work.






.
 
Back
Top