convert data from horizontal to vertical

premsi

New Member
Joined
Apr 8, 2018
Messages
8
Could someone please help me with vba coding for the below excel query

raw data

namescorenamescorenamescore
zen32men22ken58
ran45den23shen56
connor66junior24zenith25

<colgroup><col width="64" span="6" style="width:48pt"> </colgroup><tbody>
</tbody>

Seeking the refine data as below

namescore
zen32
ran45
connor66
namescore
men22
den23
junior24
namescore
ken58
shen56
zenith25

<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>
</tbody>

Thanks in advance!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Try this:-
Results start "K1".
Code:
[COLOR="Navy"]Sub[/COLOR] MG08Apr59
[COLOR="Navy"]Dim[/COLOR] Ray, Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
 Ray = ActiveSheet.Cells(1).CurrentRegion
  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)
        c = c + 1
        nray(c, 1) = Ray(n, Ac)
        nray(c, 2) = Ray(n, Ac + 1)
    [COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]Next[/COLOR] Ac
Range("K1").Resize(c, 2).Value = nray
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Try this:-
Results start "K1".
Code:
[COLOR=Navy]Sub[/COLOR] MG08Apr59
[COLOR=Navy]Dim[/COLOR] Ray, Ac [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long,[/COLOR] n [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long,[/COLOR] c [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long[/COLOR]
 Ray = ActiveSheet.Cells(1).CurrentRegion
  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)
        c = c + 1
        nray(c, 1) = Ray(n, Ac)
        nray(c, 2) = Ray(n, Ac + 1)
    [COLOR=Navy]Next[/COLOR] n
[COLOR=Navy]Next[/COLOR] Ac
Range("K1").Resize(c, 2).Value = nray
[COLOR=Navy]End[/COLOR] [COLOR=Navy]Sub[/COLOR]
Regards Mick[/Thank you so much Mick, you made my day!]
 
Upvote 0

Forum statistics

Threads
1,216,076
Messages
6,128,670
Members
449,463
Latest member
Jojomen56

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