Transpose at blank cell

JMACACK

New Member
Joined
Mar 4, 2016
Messages
3
Dear All,

I have a column of data that contains addresses as a list. Some of these span 5 lines, some span 6, 7 etc. All are broken by a blank row however.

Company A
Smith Road , The Square
Smith Street
London
W1 7EQ
Company B
Unit 11
Industrial Park Ltd.
Downton Street
Washington
West Sussex
RH20 4YB

<colgroup><col></colgroup><tbody>
</tbody>

I wish to transpose these so that I have a table type format rather than a list;

Company | Add 1 | etc.

Company A | Smith Road, The Square | etc.
Company B | Unit 11 | etc.

Aside from CTRL+C, Transpose for every address (list is about 6,000 rows) any idea how to do this?

All help appreciated!

Cheers.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
run simple macro:
Code:
Sub test()
Dim inputdata, outdata(), lastrow&, i&, inprow&, outrow&, outcol&, maxcol&
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
inputdata = Range("A1").Resize(lastrow).Value
ReDim outdata(1 To lastrow \ 2, 1 To 10)
outrow = 1
For i = 1 To lastrow
  If inputdata(i, 1) = "" Then
    outrow = outrow + 1
    outcol = 0
  Else
    outcol = outcol + 1
    If outcol > 10 Then
      MsgBox "Something went wrong. In row " & i & " there is more than 10 rows of running data", vbCritical
      Rows(i).Select
      Exit Sub
    End If
    outdata(outrow, outcol) = inputdata(i, 1)
    If outcol > maxcol Then maxcol = outcol
  End If
Next i
Range("C1").Resize(outrow, maxcol).Value = outdata
End Sub

If you never did it, press :

Alt+F11 (opens VBE)
Alt+I, M (inserts new module in your file)
copy the code posted above to the module window
Alt+F4 to return to the spreadsheet, (closes VBE)
save file as yourfilename.xlsm (macro enabled format)
Alt+F8 (macro run)
select macro test and press "Run"

your output is in cells C1 and right/down
 
Last edited:
Upvote 0
Assuming you data starts in cell A1, give this macro a try...
Code:
Sub TransposeCompanies()
  Dim Ar As Range
  Application.ScreenUpdating = False
  With Range("A1", Cells(Rows.Count, "A").End(xlUp))
    For Each Ar In .SpecialCells(xlConstants).Areas
      Ar(1).Resize(, Ar.Rows.Count) = Application.Transpose(Ar)
    Next
    .Offset(, 1).SpecialCells(xlBlanks).EntireRow.Delete
  End With
  Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi Kaper,

Thanks for much for your reply. Alas, I got a couple of errors when trying to run this macro (different ones on different worksheets, strangely!). Anyway, managed to sort it with the macro below.

Thanks.

"
 
Upvote 0
Hi Rick,

Macro worked great and all data appears as requested! Any suggestions of good resources to get more familiar with the VBA / Macro side of Excel?

I feel I have kind of gone as far as I can without understanding this side better.

Regards
 
Upvote 0
Hi,

Well, there are numerous books and online courses.
It's not that easy to say which one will suit you best.
I probably personaly got most from being active on such forums like this one (I'm not really active here, because I'm missing opportunity to post attachments) and excelforum.com or excelforum.pl (in Polish).

There is also a lot of good (and lot of bad too) tutorials on youtube and other video-sites.

Can't really name best one.
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,399
Members
449,447
Latest member
M V Arun

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