Plot data from rows into columns

MacPro

New Member
Joined
Feb 26, 2014
Messages
4
Hi All,

I have fields in rows for each record. Need to plot the same in columns. Data is in sequence i.e. each record starts with field name "ACCOUNT". Actual data is more than 10K and i need solution in VBA or other way by which data could be plotted in required pattern till end of data is reached.


ACCOUNT
1001
CITY
Sydney
DOB
19901104
ACCOUNT
1002
CITY
London
DOB
19850912
ACCOUNT
1003
CITY
Houston
DOB
19931022

Thanks
 

Attachments

  • Rows Data.png
    Rows Data.png
    15.1 KB · Views: 9

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
how about putting this behind the sheet with the data on it and running it?
VBA Code:
Function run_current_test()

Dim r As Range
Dim nextValueRef As String
Dim CRow As Long
Dim CCol As String
Dim DRow As Long
Dim DCol As String
Dim ERow As Long
Dim ECol As String
Dim Dl As String

CRow = 2
CCol = "C"
DRow = 2
DCol = "D"
ERow = 2
ECol = "E"

    With ActiveSheet
        For Each r In .Range("a1", Range("a1").End(xlDown))
            Select Case r
                Case "ACCOUNT"
                    Range(CCol & CStr(CRow)) = r
                    CRow = CRow + 1
                    nextValueRef = "ACCOUNT"
                Case "CITY"
                    Range(DCol & CStr(DRow)) = r
                    DRow = DRow + 1
                    nextValueRef = "CITY"
                Case "DOB"
                    Range(ECol & CStr(ERow)) = r
                    ERow = ERow + 1
                    nextValueRef = "DOB"
                Case Else
                    Select Case nextValueRef
                        Case "ACCOUNT"
                            Range(CCol & CStr(CRow)) = r
                            CRow = CRow + 1
                        Case "CITY"
                            Range(DCol & CStr(DRow)) = r
                            DRow = DRow + 1
                        Case "DOB"
                            Range(ECol & CStr(ERow)) = r
                            ERow = ERow + 1
                    End Select
                End Select
        Next r
    End With
                
End Function
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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