Need help with conditional transpose

kalique

New Member
Joined
Jan 22, 2007
Messages
4
Hi all,

I have a table like this:

Smt1 Smt 2
a 1
a 2
a 4
b 5
b 6
c 8
c 7
d 9
d 10
e 11
e 24
e 25

(not unique) (unique key

Now I want to have a function that transpose the Smt2 column when the first column repeat. For example:

Smt 1 Smt2
a 1 2 4
b 5 6
c 8 7

...

Plz help me. Thank you very much!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Thank you very much.

I have another question on this:

I did like above to transpose from col -> row to concatenate all the column together by symbol, for example " + " then perform eliminating. Now is there a quick way to do the other way. For example:

a1 b1 + b2 + b3
a2 b1 + b3 + b4

to

a1 b1
a1 b2
a1 b3
...

Thanks,
Kalique
 
Upvote 0
Assuming tht the concatanated values are in col B:

Code:
Sub CopyRowsToCols()
    Dim i As Integer
    Dim lngRow As Long
    Dim rngCurr As Range
    Dim strSpl
    lngRow = [B65536].End(xlUp).Row
    
    Do While lngRow > 0
        Set rngCurr = Range("b" & lngRow)
        If InStr(1, rngCurr, "+") > 0 Then
            strSpl = Split(rngCurr, "+")
            rngCurr.Offset(1, 0).Resize(UBound(strSpl), 1).Rows.EntireRow.Insert
            For i = UBound(strSpl) To 0 Step -1
                rngCurr.Offset(i, 0) = Trim(strSpl(i))
                rngCurr.Offset(i, -1) = rngCurr.Offset(0, -1)
            Next i
        End If
        lngRow = lngRow - 1
    Loop
    
End Sub

Change the lngRow > 0 to the starting row number.
 
Upvote 0
Hi kalique:

VBA is th way to go on this.

However, in reference to your first question, following is a formula based solution ...
Book1
ABCDEFG
1Field1Field2uniqueValuesFromColumnA
2a1intermediaryColumnField1
3a21a124
4a44b56 
5b56c87 
6b68d910 
7c810e   
8c7
9d9
10d10
11e11
12e24
13e25
Sheet1 (2)


cells D3:D7 show unique values from column A

formula in cell C3 is ... =MATCH(D3,$A$2:$A$13,0)
this is then copied down

formula in cell E3 is ... =IF(COLUMNS($A:A)>$C4-$C3,"",INDEX($B$2:$B$13,COLUMNS($A:A)+$C3-1))
this is then copied across and down.
 
Upvote 0

Forum statistics

Threads
1,221,829
Messages
6,162,232
Members
451,756
Latest member
tommyw

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