Column cleanup

ineedadedt

Board Regular
Joined
Jan 7, 2004
Messages
163
Hi all,

I did a search but couldn't find what I was looking for. I have this macro (thanks to this board!) that is able to breakdown my sheet 1 into sheet 2.

I would like to update this macro or create a new one to do the following:
A. Currently the macro takes all the information in the highlighted column and transposes it from vertical information to horizontal. However, I need to run it multiple times as I have sometimes 40+ columns. I would like the macro to run 1 time on sheet 1 and have it breakdown the information the same way into sheet 2 with a blank row in between to show a separation in each column.

this is the macro:


Sub test()
Dim myAreas As Areas, myArea As Range
With Sheets("sheet1")
With .Range("a1", .Range("a" & Rows.Count).End(xlUp))
On Error Resume Next
Set myAreas = .SpecialCells(2).Areas
On Error GoTo 0
If myAreas Is Nothing Then Exit Sub
For Each myArea In myAreas
If (myArea.Rows.Count > 1) * (n > 0) Then
Sheets("sheet2").Cells(n,2).Resize(,myArea.Rows.Count).Value = _
Evaluate("transpose(sheet1!" & myArea.Address & ")")
Else
n = n + 1
Sheets("sheet2").Cells(n,1).Value = myArea.Value
End If
Next
End With
End With
End Sub

Any help is greatly appreciated!

Eric
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,012
Messages
5,834,907
Members
430,326
Latest member
tomwax46

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
Top