Copy Fill Row to other Sheet

aliikhlaq2006

New Member
Joined
Apr 4, 2012
Messages
44
Pseudo Code
If any cell between (A1:D9) have color orange than
Select the row of that orange cell and copy to the other sheet first available empty row and put current date to right side of copy row

I have write some code but its not working

Sub copy_next_Row2()
If Sheet1.Range("D1:D9").Interior.Color = RGB(255, 192, 0) Then
Sheet1.Range("A1:D9").Copy
Sheet2.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
Sheet2.Range("E" & Rows.Count).End(xlUp).Offset(1, 0).Value = Date
Else
MsgBox "There is no change"
End If


End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
How are you coloring the cells normally or with conditional formatting? what version of Excel are you running?
Is
If any cell between (A1:D9) have color orange than
correct? or is it D1:D9 as you are sort of referencing in the If statement in the code?
 
Upvote 0
How are you coloring the cells normally or with conditional formatting? what version of Excel are you running?
Is correct? or is it D1:D9 as you are sort of referencing in the If statement in the code?
Yes coloring is done from conditional formatting and yes D1:D9 is reference
 
Upvote 0
You didn't answer an important question (especially with your answer to the formatting) which was what version of Excel you are using, so assuming you are using Excel 2010 or later try...

Code:
Sub copy_next_Row2()
    Dim mycell As Range
    For Each mycell In Sheet1.Range("D1:D9")
        If mycell.DisplayFormat.Interior.Color = RGB(255, 192, 0) Then
            Range(Cells(mycell.Row, "A"), Cells(mycell.Row, "D")).Copy
            Sheet2.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
            Sheet2.Range("E" & Rows.Count).End(xlUp).Offset(1, 0).Value = Date
        End If
    Next
    Application.CutCopyMode = False
End Sub
 
Last edited:
Upvote 0
Actually a bit lazy (and incorrect) with the previous code so try the code below...

Code:
Sub copy_next_Row2()
    Dim mycell As Range, i As Long
    Application.ScreenUpdating = False
    i = 0
    For Each mycell In Sheet1.Range("D1:D9")
        If mycell.DisplayFormat.Interior.Color = RGB(255, 192, 0) Then
            Sheet1.Range(Sheet1.Cells(mycell.Row, "A"), Sheet1.Cells(mycell.Row, "D")).Copy
            Sheet2.Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
            Sheet2.Range("E" & Rows.Count).End(xlUp).Offset(1, 0).Value = Date
            i = i + 1
        End If
    Next
    If i = 0 Then MsgBox "There is no change"
    With Application
        .CutCopyMode = False
        .ScreenUpdating = True
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top