How to create marcro to parse and tranpose excel data

boyitlog

New Member
Joined
Mar 6, 2011
Messages
1
I would like to create an excel macro to parse data from this:

name NN
site SA
cell CA
dataA DTACA
dataB DTBCA
dataC DTCCA
dataE DTECA
dataF DTFCA
end #
name NN
site SA
cell CB
dataA DTACB
dataB DTBCB
dataC DTCCB
dataE DTECB
dataF DTFCB
end #
name NN
site SA
cell CC
dataA DTACC
dataB DTBCC
dataF DTFCC
end #

to this:

name site cell dataA dataB dataC dataE dataF
NN SA CA DTACA DTBCA DTCCA DTECA DTFCA
NN SA CB DTACB DTBCB DTCCB DTECB DTFCB
NN SA CC DTACB DTBCB DTFCC

Any help will be much appreciated.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Something like this should work for you:

Code:
Dim lngLastRow As Long
Dim lngCTRx As Long
Dim lngCTRy As Long
Dim strTransposedValues As String
    lngCTRy = 1
    lngLastRow = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row
    For lngCTRx = 1 To lngLastRow
        If UCase(Split(Range("A" & lngCTRx).Value, " ")(0)) = "NAME" Then
           strTransposedValues = Split(Range("A" & lngCTRx).Value, " ")(1) & " "
        ElseIf UCase(Split(Range("A" & lngCTRx).Value, " ")(0)) = "END" Then
           Range("D" & lngCTRy).Value = Left(strTransposedValues, Len(strTransposedValues) - 1)
           lngCTRy = lngCTRy + 1
        Else
            strTransposedValues = strTransposedValues & Split(Range("A" & lngCTRx).Value, " ")(1) & " "
        End If
    Next lngCTRx
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,848
Members
452,948
Latest member
UsmanAli786

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