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
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Watch MrExcel Video

Forum statistics

Threads
1,122,401
Messages
5,595,939
Members
414,034
Latest member
torreyanderson

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