How to looping through data and copy to new sheet if condition is met in VBA

XcelNoobster

New Member
Joined
Jun 7, 2022
Messages
40
So I have an excel sheet called Data that has up to Column I. My data start on row 4. I want to loop through all n rows and copy all the data, but don't copy the row where Column G is empty AND Column H is 0. How would the macro look like? I know the logic, but the syntax is very confusing for me.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Welcome to the Board!

How about just using an Advanced Filter to filter the records you want and copy to a new location?
Here is a link that shows you how to do that: How to copy data to another worksheet with Advanced Filter in Excel?

If you really want VBA, here is a link that shows you how you can filter and copy just the visible rows via VBA code:
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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