Transposing Numbers

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,603
Office Version
  1. 2021
Platform
  1. Windows
I have and would like to transpose all if these one below the other. Have shown example of what it must look like after transposing the data

I have a huge amount of data to transpose




Excel 2012
ABCDE
13300433005330073300833009
23300333006
33324433245332473324833249
43324333246
53302433025330273302833029
6
733004
833005
933007
1033008
1133009
1233006
1333245
1433247
1533248
1633249
1733246
1833025
1933027
2033028
2133029
Sheet1
 
Thanks for your help Mark. Your code works perfectly and is super fast
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi Howard,

You are most welcome of course, but most of that was Rick's, just a couple of differences.

Happy coding :-)

Mark
 
Upvote 0
howard,

My screenshots show that the macro worked correctly.

Do my screenshots show what your raw looks like, and, what the results should look like?

If not, can we see what your raw data actually looks like?


Can you post a screenshot of the actual raw data worksheet?

And, can you post a screenshot of the worksheet results (manually formatted by you) that you are looking for?

To post your data, you can download and install one of the following two programs:
1. MrExcel HTMLMaker20101230
https://onedrive.live.com/?cid=8cffdec0ce27e813&sc=documents&id=8CFFDEC0CE27E813!189

Installation instructions here:
http://www.mrexcel.com/forum/board-announcements/515787-forum-posting-guidelines.html#post2545970

2. Excel Jeanie
Download


If you are not able to give us screenshots:
You can upload your workbook to Box Net,
sensitive data changed
mark the workbook for sharing
and provide us with a link to your workbook.
 
Upvote 0
Thanks for your reply and input

This is how it looks before being transposed


Excel 2012
ABCDEFG
14700N173016173018
24700U173066173068
34701173022173072173222173272
44704N173020
54704U173070173220173270
64720173266173268
74721173216173218
84730N173612
94730U173662173712
104731N173614
114731U173664173714
124733173616173666173716173766173816
134736173316173318173320173322173812173814
144737173912
154746174070177023
164750173762
174751173764
18
19
Sheet1



This is how it looks after being transposed


Excel 2012
A
1173016
2173018
3173066
4173068
5173022
6173072
7173222
8173272
9173020
10173070
11173220
12173270
13173266
14173268
15173216
16173218
17173612
18173662
19173712
20173614
21173664
22173714
23173616
24173666
25173716
26173766
27173816
28173316
29173318
30173320
31173322
32173812
33173814
34173912
35174070
36177023
37173762
38173764
Sheet2
 
Upvote 0
howard,

Thanks for the screenshots.

Sample raw data in worksheet Sheet1:


Excel 2007
ABCDEFG
14700N173016173018
24700U173066173068
34701173022173072173222173272
44704N173020
54704U173070173220173270
64720173266173268
74721173216173218
84730N173612
94730U173662173712
104731N173614
114731U173664173714
124733173616173666173716173766173816
134736173316173318173320173322173812173814
144737173912
154746174070177023
164750173762
174751173764
18
Sheet1


After the macro (using two arrays in memory) in worksheet Sheet2:


Excel 2007
A
1173016
2173018
3173066
4173068
5173022
6173072
7173222
8173272
9173020
10173070
11173220
12173270
13173266
14173268
15173216
16173218
17173612
18173662
19173712
20173614
21173664
22173714
23173616
24173666
25173716
26173766
27173816
28173316
29173318
30173320
31173322
32173812
33173814
34173912
35174070
36177023
37173762
38173764
39
Sheet2


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Code:
Sub ReorgData_V2()
' hiker95, 09/07/2014, ME803687
Dim w1 As Worksheet, w2 As Worksheet
Dim a As Variant, o As Variant
Dim i As Long, j As Long, c As Long
Dim lr As Long, lc As Long, n As Long
Set w1 = Sheets("Sheet1")
Set w2 = Sheets("Sheet2")
With w1
  lr = .Cells.Find("*", , xlValues, xlWhole, xlByRows, xlPrevious, False).Row
  lc = .Cells.Find("*", , xlValues, xlWhole, xlByColumns, xlPrevious, False).Column
  a = .Range(.Cells(1, 1), .Cells(lr, lc))
  n = Application.Count(.Range(.Cells(1, 2), .Cells(lr, lc)))
  ReDim o(1 To n, 1 To 1)
End With
For i = 1 To lr
  For c = 2 To lc
    If a(i, c) <> "" Then
      j = j + 1
      o(j, 1) = a(i, c)
    End If
  Next c
Next i
With w2
  .UsedRange.ClearContents
  .Cells(1, 1).Resize(n, 1).Value = o
  .Columns(1).AutoFit
  .Activate
End With
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm

Then run the ReorgData_V2 macro.
 
Upvote 0
Thanks for the help, much appreciated. At first Macro did not work, but once I converted the data to numbers on Sheet1, code then ran perfectly
 
Upvote 0
howard,

Thanks for the feedback.

You are very welcome. Glad I could help.

And, come back anytime.
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,081
Members
453,021
Latest member
Justyna P

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