Copy multiple first non blank cells in data with gaps

marc01

Board Regular
Joined
Sep 17, 2018
Messages
50
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

I have to columns of data and I am looking to copy the first non blank value and move it to the adjacent cell. The raw data looks like this:

-1
0
-1
-2
-3
-2
-1
0
1
2
3
4
3
4
5
4
3
2
1
0
1
0
1

<tbody>
</tbody>

In the first instance I would like to copy -3 in the 2nd column and paste it under the -2 in the first column.
Then copy the 2 in the first column (2nd set of rows) and paste it underneath the 1 in the first set of data in the 2nd column.
And so on (for a variable number of times)

Below I have highlighted the values in the above example:
-1
0
-1
-2
-3-3
-2
-1
0
1
22
3
4
3
4
55
4
3


<tbody>
</tbody>

<tbody>
</tbody>
Many thanks!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Perhaps this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG13Dec47
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, R [COLOR="Navy"]As[/COLOR] Range
 [COLOR="Navy"]Set[/COLOR] Rng = Range("A:A").SpecialCells(xlCellTypeBlanks)
 [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] R [COLOR="Navy"]In[/COLOR] Rng.Areas
    R(1) = R(1).Offset(, 1)
    R(R.Count)(1).Offset(1, 1) = R(R.Count + 1)
[COLOR="Navy"]Next[/COLOR] R
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Mick that works perfectly! I have no idea what it means or how to read it :confused::( however thank you very much!

I did try to record a macro by using ctrl+down arrow to get to bottom of data set, copy the desired value, arrow left (or right depending on which column I was in - it would alternate each time), then paste.....however I didn't know how to make this loop until no values were remaining.

Again thanks for your help.

All the best.

Marc
 
Upvote 0

Forum statistics

Threads
1,213,563
Messages
6,114,329
Members
448,564
Latest member
ED38

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