Macro to Transpose All Items in a Vertical List, and Add a Comma

  • Thread starter Thread starter ryguy7272
  • Start date Start date
R

ryguy7272

I am looking around for a simple macro that takes all items in a used range
in a vertical column, transposes the data set, and adds a comma to the end if
each item before the next item is put into the next cell to the right.

Regards,
Ryan---
 
I just found the code below:

Sub oneLoveUmmmRow()
Dim wsF As Worksheet, WST As Worksheet
Dim rf As Range, rT As Range

' initialize
Set wsF = ActiveSheet
Set WST = Sheets.Add
WST.Name = "Results"
Set rf = wsF.Range("A1")
Set rT = WST.Range("A1")

' rf loops through all the values in wf
' rt just moves across the sheet popping values until rf is done
Do While Not rf.Value = ""
Do While Not rf.Value = ""
rT.Value = rf.Value & ","
Set rT = rT.Offset(0, 1)
Set rf = rf.Offset(0, 1) ' move rf one space right
Loop
Set rf = wsF.Range("A" & rf.Row + 1) ' move rf to the start of the
next row
Loop

' clean up
Set rf = Nothing
Set rT = Nothing
Set wsF = Nothing
Set WST = Nothing
End Sub

It did what I wanted after a small modification.
Thanks to all who looked. Hopefully this helps someone else.

Regards,
Ryan---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top