Copy and paste when a condition is met (Condition is not in row to be copied)

jakekue311

New Member
Joined
Mar 27, 2018
Messages
1
Hello,
This is my first time posting to ask questions about VBA, but I will do my best to provide all relevant information.

Here is what I would like to do:
I want to create an if statement that copies and pastes rows from a separate workbook into another, only when a certain condition is met. This condition is based on the sum of the pasted rows and is, therefore, not within the row itself. I understand how to write a code that would pick out all of the rows that contain a certain value, but what I do not understand is how to have it meet a condition on another workbook and then choose to copy and paste or not.

Here is the code that I tried:




For i = 2 To 10000
If Workbooks("daily_test").Worksheets("Daily").Cells(B6).Value = 0 Then
Workbooks("daily_data").Worksheets("Sheet1").Rows(i).Copy
b = Workbooks("daily_test").Worksheets("Daily").Cells(Rows.Count, 1).End(xlUp).Row
Workbooks("daily_test").Worksheets("Daily").Cells(b + 1, 1).Select
ActiveSheet.Paste
End If
Next

I am using excel 2010.

Thank you in advance for any help you may be able to provide!
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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