ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compare data, and if different, copy to another worksheet (https://www.excelbanter.com/excel-programming/438839-compare-data-if-different-copy-another-worksheet.html)

bugsyb

Compare data, and if different, copy to another worksheet
 
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.

JLGWhiz[_2_]

Compare data, and if different, copy to another worksheet
 
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.



"bugsyb" wrote in message
...
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.




bugsyb

Compare data, and if different, copy to another worksheet
 
It worked perfectly! Thank you so much!

bugsyb

"JLGWhiz" wrote:

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.



"bugsyb" wrote in message
...
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.



.



All times are GMT +1. The time now is 09:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com