Macro to Tranpose Data

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,585
Office Version
  1. 2021
Platform
  1. Windows
I have data in Col F1 to M10 (max) that contains Data


I would like a macro or formula to transpose this data in Cell F15 Onwards

See Sample data below that needs to be transposed


Excel 2012
FGHIJKL
1KN-63301KN-63311KN-97260KN-97305KN-97290KN-97310KN-94300
2KN-63304KN-63314KN-97300KN-97325KN-97330
3KN-63303KN-63313KN-63314KN-63315
4
Sheet1
 
Last edited:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi Rick

Thanks for the reply

I need a single row down from F15 onwards
 
Upvote 0
Hi Rick

Thanks for the reply

I need a single row down from F15 onwards
Okay, now, in what order? Using addresses only, which of these is the order for the transposing...
F15=>F1F1
F16=>F2G1
F17=>F3orH1
F18=>G1I1
etc.etc.etc.

<tbody>
</tbody>
 
Upvote 0
Thanks for the reply


The Data must be transposed from eg F1 to M1, then F2 to M2 etc in F15 , F16 onwards

See Sample data of data manually transposed



Excel 2012
F
14
15KN-63301
16KN-63311
17KN-97260
18KN-97305
19KN-97290
20KN-97310
21KN-94300
22KN-94301
23KN-63304
24KN-63314
25KN-97300
26KN-97325
27KN-97330
28KN-63303
29KN-63313
30KN-63314
31KN-63315
Sheet1
 
Upvote 0
The Data must be transposed from eg F1 to M1, then F2 to M2 etc in F15 , F16 onwards
Assuming your posted example data is representative of your actual data, give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub TransposeColumnsFthruM()
  Dim R As Long, C As Long, LastRow As Long, Joined As Variant
  Range("F15:F112").Clear
  LastRow = 14
  For R = 1 To Range("F1").CurrentRegion.Rows.Count
    Joined = Split(Trim(Join(Application.Index(Cells(R, "F").Resize(, 8).Value, 1, 0))))
    Cells(LastRow + 1, "F").Resize(UBound(Joined) + 1) = Application.Transpose(Joined)
    LastRow = LastRow + UBound(Joined) + 1
  Next
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
Hi Rick

I have run your code on another file & get type Mismatch and the following code is highlighted

Code:
 Cells(LastRow + 1, "F").Resize(UBound(Joined) + 1) = Application.Transpose(Joined)

Please test and advise


See Sample Data. Col E is data I inputted and Col F to M contains a Formula

Need to Transpose Data Col F1 to the last items row on Col M containing Data



Excel 2012
EFGHIJKLM
16721883216883218883200883202883208883210  
26983887400
36500A883003
46600M883104883105883114883115883004883005883014883015
Sheet1
Cell Formulas
RangeFormula
F1{=IF(COLUMNS($F1:F1)>COUNTIF($A$1:$A$4000,$E1),"",INDEX($B$1:$B$4000,SMALL(IF($A$1:$A$4000=$E1,ROW($A$1:$A$4000)-ROW($A$1)+1),COLUMNS($F1:F1))))}
G1{=IF(COLUMNS($F1:G1)>COUNTIF($A$1:$A$4000,$E1),"",INDEX($B$1:$B$4000,SMALL(IF($A$1:$A$4000=$E1,ROW($A$1:$A$4000)-ROW($A$1)+1),COLUMNS($F1:G1))))}
H1{=IF(COLUMNS($F1:H1)>COUNTIF($A$1:$A$4000,$E1),"",INDEX($B$1:$B$4000,SMALL(IF($A$1:$A$4000=$E1,ROW($A$1:$A$4000)-ROW($A$1)+1),COLUMNS($F1:H1))))}
I1{=IF(COLUMNS($F1:I1)>COUNTIF($A$1:$A$4000,$E1),"",INDEX($B$1:$B$4000,SMALL(IF($A$1:$A$4000=$E1,ROW($A$1:$A$4000)-ROW($A$1)+1),COLUMNS($F1:I1))))}
J1{=IF(COLUMNS($F1:J1)>COUNTIF($A$1:$A$4000,$E1),"",INDEX($B$1:$B$4000,SMALL(IF($A$1:$A$4000=$E1,ROW($A$1:$A$4000)-ROW($A$1)+1),COLUMNS($F1:J1))))}
K1{=IF(COLUMNS($F1:K1)>COUNTIF($A$1:$A$4000,$E1),"",INDEX($B$1:$B$4000,SMALL(IF($A$1:$A$4000=$E1,ROW($A$1:$A$4000)-ROW($A$1)+1),COLUMNS($F1:K1))))}
L1{=IF(COLUMNS($F1:L1)>COUNTIF($A$1:$A$4000,$E1),"",INDEX($B$1:$B$4000,SMALL(IF($A$1:$A$4000=$E1,ROW($A$1:$A$4000)-ROW($A$1)+1),COLUMNS($F1:L1))))}
M1{=IF(COLUMNS($F1:M1)>COUNTIF($A$1:$A$4000,$E1),"",INDEX($B$1:$B$4000,SMALL(IF($A$1:$A$4000=$E1,ROW($A$1:$A$4000)-ROW($A$1)+1),COLUMNS($F1:M1))))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Since I don't have a data set for Columns A:B, I cannot produce the result set you have in the range F1:M4, so I made up a formula that fills in the data layout you show. No matter what I try, I cannot make my code fail... it works consistently for me. Can you post a copy of your workbook (sensitive data removed) to DropBox (or some other such file sharing service) so I can download it and watch my code fail... that would allow me to trace the problem directly.
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

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