VBA Code to Copy Non-Empty Cells in Range

Jacob1

New Member
Joined
Jun 16, 2014
Messages
34
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:
ABCD
1z
2123
3
4
5y
6qrt
7456
8147

<tbody>
</tbody>

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:


ABCD
1z
2123
3y
4qrt
5456
6147

<tbody>
</tbody>

So basically, the code "compresses" the data into a summary sheet. Any help would be greatly appreciated.

Thanks!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,216,743
Messages
6,132,462
Members
449,729
Latest member
davelevnt

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