Loop through all cells in worksheet a, copy and consolidate to b minus blanks

RobGEOD

New Member
Joined
Oct 25, 2016
Messages
19
I have data in columns A:AN rows 1-50. I need to loop through all even number columns and if the cell has data copy it and the cell to the left to another worksheet in order to consolidate. Below is an example:

Data
[TABLE="width: 500"]
<tbody>[TR]
[TD]1[/TD]
[TD]aaaaaaaa[/TD]
[TD]11[/TD]
[TD]bbbbbb[/TD]
[TD]21[/TD]
[TD]cccccc[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]aaaaaaaa[/TD]
[TD]12[/TD]
[TD][/TD]
[TD]22[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD]13[/TD]
[TD][TABLE="width: 500"]
<tbody>[TR]
[TD]bbbbbb[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]23[/TD]
[TD]cccccc[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]aaaaaaaa[/TD]
[TD]14[/TD]
[TD][TABLE="width: 500"]
<tbody>[TR]
[TD]bbbbbb[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]24[/TD]
[TD]cccccc[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]aaaaaaaa[/TD]
[TD]15[/TD]
[TD][TABLE="width: 500"]
<tbody>[TR]
[TD]bbbbbb[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]25[/TD]
[TD]cccccc[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]aaaaaaaa[/TD]
[TD]16[/TD]
[TD][/TD]
[TD]26[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]aaaaaaaa[/TD]
[TD]17[/TD]
[TD][/TD]
[TD]27[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]aaaaaaaa[/TD]
[TD]18[/TD]
[TD][TABLE="width: 500"]
<tbody>[TR]
[TD]bbbbbb[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]28[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]aaaaaaaa[/TD]
[TD]19[/TD]
[TD][TABLE="width: 500"]
<tbody>[TR]
[TD]bbbbbb[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]29[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD][/TD]
[TD]20[/TD]
[TD][TABLE="width: 500"]
<tbody>[TR]
[TD]bbbbbb[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]30[/TD]
[TD]cccccc[/TD]
[/TR]
</tbody>[/TABLE]


Desired Output
[TABLE="width: 500"]
<tbody>[TR]
[TD]1[/TD]
[TD]aaaaaaaa[/TD]
[TD]14[/TD]
[TD]bbbbbb[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]aaaaaaaa[/TD]
[TD]15[/TD]
[TD]bbbbbb[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]aaaaaaaa[/TD]
[TD]18[/TD]
[TD]bbbbbb[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]aaaaaaaa[/TD]
[TD]19[/TD]
[TD]bbbbbb[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]aaaaaaaa[/TD]
[TD]20[/TD]
[TD]bbbbbb[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]aaaaaaaa[/TD]
[TD]21[/TD]
[TD]cccccc[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]aaaaaaaa[/TD]
[TD]23[/TD]
[TD]cccccc[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]aaaaaaaa[/TD]
[TD]24[/TD]
[TD]cccccc[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]bbbbbb[/TD]
[TD]25[/TD]
[TD]cccccc[/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]bbbbbb[/TD]
[TD]30[/TD]
[TD]cccccc[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,223,912
Messages
6,175,341
Members
452,638
Latest member
Oluwabukunmi

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