Help with interleaving 2 columns to 1 row with blank cells

Goliath.ro

New Member
Joined
Aug 26, 2011
Messages
3
Hello

I am trying to cut timp spent copy pasting information with some functions macros but my knowledge in this area is extremly limited, all I did so far is from what I learned on my own

So I have 2 columns with data that I want wrinte into a row interleaved, but primary column also has spaces

so its like
Code:
   A     B
 aaaa   11
        22
 bbbb   44
        55
        66

to:
aaaa 11 22 bbbb 44 55 66
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try this, Results start "C1".
Code:
[COLOR="Navy"]Sub[/COLOR] MG26Aug36
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("B1"), Range("B" & Rows.Count).End(xlUp))
ReDim Ray(1 To Rng.Count * 2)
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
 c = c + 1
    [COLOR="Navy"]If[/COLOR] Dn.Offset(, -1) <> "" [COLOR="Navy"]Then[/COLOR]
        Ray(c) = Dn.Offset(, -1)
        c = c + 1
        Ray(c) = Dn
    [COLOR="Navy"]Else[/COLOR]
        Ray(c) = Dn
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
Range("c1").Resize(, c) = Ray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Thank you very much that works exceptionally well, I have adapted it to my actual rows and columns and I am so very happy right now :)
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,421
Members
452,913
Latest member
JWD210

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