Copy/paste row if a condition is met

kobe

New member
Local time
Today, 00:14
Joined
Apr 2, 2012
Messages
1
I need to copy all data from Sheet 1, cells A2:K33947 if the cell in column H is blank. (Cells in Column H are either blank or ='Duplicate' following the same formula.

When I say copy and paste, I am not certain that is the right term. A:K is all references that appear correctly in worksheet 2 if I input into cell a2=sheet1!A2 but do not appear correctly in sheet 2 if I simply paste.
 
I'm not entirely sure if I completely understand what you are trying to do, but here is some code that could work.

Code:
    Sheets("Sheet1").Select
    RowNum = 1
    Do While RowNum < 33947
    If Cells(RowNum, "H") = "" Then
        Range(Cells(RowNum, "A"), Cells(RowNum, "K")).Select
        Selection.copy
        Sheets("Sheet2").Select
        Range(Cells(RowNum, "A")).Select
        ActiveSheet.Paste
        Sheets("Sheet1").Select
    End If
    Loop

That will look at each line and if H is not empty it will copy and paste the values into sheet2 (make sure your sheets are named properly or change the code).

If you post an example file it'll be easier to help you solve your problem.
 

Users who are viewing this thread

Back
Top Bottom