Hello all,
I have very little experience with VBA, but I'm trying to write a code that will copy cells in a range that are not empty, then continue down the column to the next range and copy those values until another non-empty cell appears, then move to the next range. For instance:
I have a sheet with the following values: [TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]z[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]y[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD]q[/TD]
[TD]r[/TD]
[TD]t[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD][/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]7[/TD]
[/TR]
</tbody>[/TABLE]
I want the code to check if cell is empty in range B2:B4, and when it gets to an empty cell (B3) then move to next range (B6:B8), but if non-empty, copy cells (A1:D2) into a different sheet then move to next range and copy those non-empty cells in that range like this:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]z[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]y[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD]q[/TD]
[TD]r[/TD]
[TD]t[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]7[/TD]
[/TR]
</tbody>[/TABLE]
So basically, the code "compresses" the data into a summary sheet. Any help would be greatly appreciated.
Thanks!
I have very little experience with VBA, but I'm trying to write a code that will copy cells in a range that are not empty, then continue down the column to the next range and copy those values until another non-empty cell appears, then move to the next range. For instance:
I have a sheet with the following values: [TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]z[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]y[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD]q[/TD]
[TD]r[/TD]
[TD]t[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD][/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]7[/TD]
[/TR]
</tbody>[/TABLE]
I want the code to check if cell is empty in range B2:B4, and when it gets to an empty cell (B3) then move to next range (B6:B8), but if non-empty, copy cells (A1:D2) into a different sheet then move to next range and copy those non-empty cells in that range like this:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]z[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]y[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD]q[/TD]
[TD]r[/TD]
[TD]t[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]7[/TD]
[/TR]
</tbody>[/TABLE]
So basically, the code "compresses" the data into a summary sheet. Any help would be greatly appreciated.
Thanks!