VBA to copy information down but on a loop

DMO123

Board Regular
Joined
Aug 16, 2018
Messages
99
I tried to run this in a macro but somehow the loop didn’t work as it kept referencing the cells when I need this to just run down until it hits the end. I am looking to do the following:
If there is a value in column D and nothing in column B then the information need to be copied down. To copy it will look for column A to match but look for the top line of the match (in this case row 1 and 7) so there is values in column B. once it find the top row the code should copy down rows B,E & H

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]AAA[/TD]
[TD]Spon[/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD]Info[/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AAA[/TD]
[TD]Spon[/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD]Info[/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AAA[/TD]
[TD][/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AAA[/TD]
[TD][/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AAA[/TD]
[TD][/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BBB[/TD]
[TD]Spon[/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD]Yes[/TD]
[TD]Info[/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BBB[/TD]
[TD]Spon[/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BBB[/TD]
[TD][/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BBB[/TD]
[TD][/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BBB[/TD]
[TD][/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Can someone help! Thanks!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Can you post the same table you posted in Message #1 but with the results you want to see placed in it?
 
Last edited:
Upvote 0
Sure the results would look something like the below highlighted in red:

[TABLE="class: cms_table_grid, width: 500"]
<tbody>[TR]
[TD]AAA[/TD]
[TD]Spon[/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD]Info[/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AAA[/TD]
[TD]Spon[/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD]Info[/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AAA[/TD]
[TD]Spon[/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AAA[/TD]
[TD]Spon[/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AAA[/TD]
[TD]Spon[/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BBB[/TD]
[TD]Spon[/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD]Yes[/TD]
[TD]Info[/TD]
[TD]01-01-18[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BBB[/TD]
[TD]Spon[/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BBB[/TD]
[TD]Spon
[/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BBB[/TD]
[TD]Spon[/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BBB[/TD]
[TD]Spon[/TD]
[TD][/TD]
[TD]01-01-18[/TD]
[TD]Unknown[/TD]
[TD]Info[/TD]
[TD]No[/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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