transpose for loop?

MR3

Board Regular
Joined
Jun 10, 2008
Messages
175
i would like to write a VB for loop that just takes the top row column headers and puts them into the first column. for example

Before
name = A1 address = B1 Number = C1

After
name = A1 address = A2 Number = A3

but the loop much go the entire top row or until it sees no more data
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try

Code:
Sub XPose()
Dim LC As Long
LC = Cells(1, Columns.Count).End(xlToLeft).Column
Cells(1, 1).Resize(LC).Value = Application.Transpose(Range(Cells(1, 1), Cells(1, LC)))
End Sub
 
Upvote 0
In a similar vein, I had

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> Swap()<br>    <SPAN style="color:#00007F">With</SPAN> Range("A1", Cells(1, Columns.Count).End(xlToLeft))<br>        .Resize(.Columns.Count, 1).Value = Application.Transpose(.Value)<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>

Not sure if the original values had to be removed?
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,219
Members
452,895
Latest member
BILLING GUY

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