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!
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!