Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
j j is offline
external usenet poster
 
Posts: 128
Default Transpose into comma-delimited row

I have several worksheets where I need to take rows of data like:
Row1 Row2
ABCDEF 12
GHIJKL 34
MNOPQR 56
And I want to transpose that into 2 comma-delimited rows like:
Row1 ABCDEF,GHIJKL,MNOPQR
Row2 12,34,56
The paste special function separates the data into columns. I probably need
to write a macro but I don't have much experience doing that. I appreciate
the help in getting this done. Thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Transpose into comma-delimited row

try this:

1. Copy the range you want to transpose
2. Select a cell on another sheet
3. Click on Paste Special under the edit menu
4. Click on the Transpose checkbox
5. Click on OK

You will have the values you copied transposed.

Hope this helps and if it does, please vote for this post.

G.Morales

"J" wrote:

I have several worksheets where I need to take rows of data like:
Row1 Row2
ABCDEF 12
GHIJKL 34
MNOPQR 56
And I want to transpose that into 2 comma-delimited rows like:
Row1 ABCDEF,GHIJKL,MNOPQR
Row2 12,34,56
The paste special function separates the data into columns. I probably need
to write a macro but I don't have much experience doing that. I appreciate
the help in getting this done. Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Transpose into comma-delimited row

Hi,
This is close, but it adds an extra "," at the very end. Run it on each
column separately, although it will work on any column, not just A & B.
Sub Macro1()
ReturnAddress = ActiveCell.Address
RowCombine = ActiveCell.Value
Do Until ActiveCell.Value = ""
ActiveCell.Offset(1, 0).Range("A1").Select
RowCombine = RowCombine & "," & ActiveCell.Value
Loop
Range(ReturnAddress).Select
ActiveCell.Value = RowCombine

End Sub

Thanks,

"J" wrote:

Sorry, that's columns of data

"J" wrote:

I have several worksheets where I need to take rows of data like:
Row1 Row2
ABCDEF 12
GHIJKL 34
MNOPQR 56
And I want to transpose that into 2 comma-delimited rows like:
Row1 ABCDEF,GHIJKL,MNOPQR
Row2 12,34,56
The paste special function separates the data into columns. I probably need
to write a macro but I don't have much experience doing that. I appreciate
the help in getting this done. Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Transpose into comma-delimited row

If your data is like this
A1="ABCDEF",B1="GHIJKL",C1="MNOPQR" (row 1), and
A2=12,B2=34,C2=56
then use this formula in D1
=A1 & "," & B1 & "," & C1
and copy the formula down to D2

If you want to automate the above process for a number of open workbooks then
create a new module and place the following code into it
Sub CreateCommaDelimitedFormula()
Dim wb As Workbook
For Each wb In Workbooks
'the following line assumes the formula is required in Sheet1 of
each
'workbook and only for Cells D1 and D2
With wb.Worksheets("Sheet1")
With .Range(.Cells(1, 4), .Cells(2, 4))
.FormulaR1C1 = "=RC[-3] & "","" & RC[-2] & "","" & RC[-1]"
End With
End With
Next wb
End Sub


Alok Joshi


"J" wrote:

I have several worksheets where I need to take rows of data like:
Row1 Row2
ABCDEF 12
GHIJKL 34
MNOPQR 56
And I want to transpose that into 2 comma-delimited rows like:
Row1 ABCDEF,GHIJKL,MNOPQR
Row2 12,34,56
The paste special function separates the data into columns. I probably need
to write a macro but I don't have much experience doing that. I appreciate
the help in getting this done. Thanks.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Transpose into comma-delimited row

Here is code that I use to create the csv and to then split the csv. It is a
little different from exactly what you want but it is close. It takes a row
of data and makes a csv line on a new sheet. Highlinght the row you want and
run the code.

Private Const m_cMaxConcatenateRows As Integer = 1000

Private Sub MakeCSV()
Dim rngCurrent As Range
Dim rngToPaste As Range
Dim intCounter As Integer
Dim wksPasteTo As Worksheet

intCounter = 0

Set rngCurrent = ActiveCell
Set wksPasteTo = Worksheets.Add
Set rngToPaste = wksPasteTo.Range("A1")

rngToPaste.NumberFormat = "@"
rngToPaste.Value = rngCurrent.Value
Set rngCurrent = rngCurrent.Offset(1, 0)

Do While rngCurrent.Value < ""
intCounter = intCounter + 1
If intCounter m_cMaxConcatenateRows Then
intCounter = 0
Set rngToPaste = rngToPaste.Offset(1, 0)
rngToPaste.Value = rngCurrent.Value
Set rngCurrent = rngCurrent.Offset(1, 0)
Else
rngToPaste = rngToPaste & ", " & rngCurrent
Set rngCurrent = rngCurrent.Offset(1, 0)
End If
Loop
End Sub

Private Sub SplitCSV()
Dim aryCSVValues As Variant
Dim rngPasteTo As Range
Dim intCounter As Integer
Dim wksPasteTo As Worksheet

aryCSVValues = Split(ActiveCell.Value, ",")
Set wksPasteTo = Worksheets.Add
Set rngPasteTo = wksPasteTo.Range("A1")

For intCounter = LBound(aryCSVValues) To UBound(aryCSVValues)
aryCSVValues(intCounter) = Trim(aryCSVValues(intCounter))
If Left(aryCSVValues(intCounter), 1) = "'" Then _
aryCSVValues(intCounter) = Right(aryCSVValues(intCounter),
Len(aryCSVValues(intCounter)) - 1)
If Right(aryCSVValues(intCounter), 1) = "'" Then _
aryCSVValues(intCounter) = Left(aryCSVValues(intCounter),
Len(aryCSVValues(intCounter)) - 1)
rngPasteTo.NumberFormat = "@"
rngPasteTo.Value = aryCSVValues(intCounter)
Set rngPasteTo = rngPasteTo.Offset(1, 0)
Next intCounter
End Sub

HTH

"J" wrote:

Sorry, that's columns of data

"J" wrote:

I have several worksheets where I need to take rows of data like:
Row1 Row2
ABCDEF 12
GHIJKL 34
MNOPQR 56
And I want to transpose that into 2 comma-delimited rows like:
Row1 ABCDEF,GHIJKL,MNOPQR
Row2 12,34,56
The paste special function separates the data into columns. I probably need
to write a macro but I don't have much experience doing that. I appreciate
the help in getting this done. Thanks.




  #6   Report Post  
Posted to microsoft.public.excel.programming
j j is offline
external usenet poster
 
Posts: 128
Default Transpose into comma-delimited row

Sorry, that's columns of data

"J" wrote:

I have several worksheets where I need to take rows of data like:
Row1 Row2
ABCDEF 12
GHIJKL 34
MNOPQR 56
And I want to transpose that into 2 comma-delimited rows like:
Row1 ABCDEF,GHIJKL,MNOPQR
Row2 12,34,56
The paste special function separates the data into columns. I probably need
to write a macro but I don't have much experience doing that. I appreciate
the help in getting this done. Thanks.


  #7   Report Post  
Posted to microsoft.public.excel.programming
j j is offline
external usenet poster
 
Posts: 128
Default Transpose into comma-delimited row

Perfect, this does exactly what I asked for. But I didn't ask for exactly
what I needed.
I am using this to modify some data in SQL and I just realized that I need
the individual values to be encapsulated in single quotes. Any ideas on that?
Thanks so much for the help.

"David" wrote:

Hi,
This is close, but it adds an extra "," at the very end. Run it on each
column separately, although it will work on any column, not just A & B.
Sub Macro1()
ReturnAddress = ActiveCell.Address
RowCombine = ActiveCell.Value
Do Until ActiveCell.Value = ""
ActiveCell.Offset(1, 0).Range("A1").Select
RowCombine = RowCombine & "," & ActiveCell.Value
Loop
Range(ReturnAddress).Select
ActiveCell.Value = RowCombine

End Sub

Thanks,

"J" wrote:

Sorry, that's columns of data

"J" wrote:

I have several worksheets where I need to take rows of data like:
Row1 Row2
ABCDEF 12
GHIJKL 34
MNOPQR 56
And I want to transpose that into 2 comma-delimited rows like:
Row1 ABCDEF,GHIJKL,MNOPQR
Row2 12,34,56
The paste special function separates the data into columns. I probably need
to write a macro but I don't have much experience doing that. I appreciate
the help in getting this done. Thanks.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving as tab delimited or comma delimited MathGrace Excel Discussion (Misc queries) 0 June 20th 08 08:02 PM
Tab delimited to comma delimited Arne Hegefors Excel Worksheet Functions 3 December 13th 07 03:08 PM
Comma Delimited-need comma at beginnng & end Tattoo Excel Discussion (Misc queries) 2 December 11th 07 04:39 PM
Comma Delimited Numbers Spannerman Excel Discussion (Misc queries) 3 April 3rd 07 08:19 AM
Comma delimited question Carol Excel Discussion (Misc queries) 2 January 15th 05 11:32 AM


All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"