Transfer Multiple Rows Data in Single Row Excluding Blanks

Dheepak

Board Regular
Joined
Aug 25, 2013
Messages
64
Hi All,

I have the data of Product in Row A and its price in row B. Similarly Product in Row C and its price in row D. in Total having 3 list of products and prices. Maximum 10 entries user can enter in each row. I want all the products from those 3 rows in single row G and its price in H without including the blanks. Here is the expectation .

A
B
C
D
E
F
G
H
Product A
Price
Product A1
Price
Product A2
Price
Product A
Price of Product A
Product B
Price
Product B1
Price
Product B
Price of Product A
Product C1
Price
Product A1
Price of Product A1
Product B1
Price of Product B1
Product C1
Price of Product C1
Product A2
Price of Product A2

<tbody>
</tbody>

Can any one please help on this.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
For data starting in "A1", try this for results starting "G1".
Code:
[COLOR="Navy"]Sub[/COLOR] MG24Jul46
[COLOR="Navy"]Dim[/COLOR] ray [COLOR="Navy"]As[/COLOR] Variant, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
ray = Range("A1").CurrentRegion.Resize(, 6)
ReDim nray(1 To UBound(ray, 1) * UBound(ray, 2), 1 To 2)

[COLOR="Navy"]For[/COLOR] Ac = 1 To UBound(ray, 2) [COLOR="Navy"]Step[/COLOR] 2
    [COLOR="Navy"]For[/COLOR] n = 1 To UBound(ray, 1)
        [COLOR="Navy"]If[/COLOR] Not IsEmpty(ray(n, Ac)) [COLOR="Navy"]Then[/COLOR]
            c = c + 1
            nray(c, 1) = ray(n, Ac)
            nray(c, 2) = ray(n, Ac + 1)
        [COLOR="Navy"]End[/COLOR] If
    [COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]Next[/COLOR] Ac
Range("G1").Resize(c, 2).Value = nray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,213,550
Messages
6,114,265
Members
448,558
Latest member
aivin

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