VBA IF statements and Copying to new worksheet

JiminyKricket

New Member
Joined
May 17, 2011
Messages
8
Hi,

Really struggling with this one..

I am trying to use an IF statement to compare a cell in a number of rows to an individual cell, i.e in cell FQ1 i have a date in the format YYYYMMDD, and i have a number of rows (varies but 3k+). If a cell in column O does NOT equal that in FQ1 then i want it to copy and paste the entire row to a new worksheet.

The bit i'm particularly struggling with is that in the new worksheet there is already a varying amount of data already inputted, and so the row has to be pasted 4 rows below the last row used.

Further to this however there will likely be numerous rows that need to be copied but they need to be below each other, i.e...

Old row---------
Old row---------
Old row---------



New Row-------
New Row-------
New Row-------
New Row-------

What i have so far is the following;

With Worksheets("Trade File")
irow = .Range("O50000").End(xlUp).Row
For i = 2 To irow
If Range("O" & i) <> Range("FQ1") Then
Range("O" & i).EntireRow.Copy
***Sheets("Facilitation Fees").Range("A" & j + 4).Row.Paste

End If
Next i

End With

Obviously the *** row is incorrect!

Many thanks in advance
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,224,566
Messages
6,179,555
Members
452,928
Latest member
101blockchains

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