7 replies
by tclere
I am not sure that there is a simple copy/paste method for this. The best solution will depend on your specific application. Here are a couple simple solutions.
1. Put this formula in the destination cell
=Sheet1!A1 & "," & Sheet1!A2 & "," & Sheet1!A3 etc.
2. Use a macro to do the dirty work
Sub CopyToCell()
Dim sVal As String, i As Integer
Dim Sht1 As Worksheet, Sht2 As Worksheet
Set Sht1 = Worksheets("Sheet1")
Set Sht2 = Worksheets("Sheet2") sVal = Sht1.Range("A1").Text
For i = 2 To 10
sVal = sVal & "," & Sht1.Range("A" & i).Text
Next i
Sht2.Range("A1").FormulaR1C1 = sVal
End Sub
Hope this gets you in the right direction.
by tclere
by new graduate
by srobertson
If the cell range will remain perpetually static or at least change irregularly then your best option would be to use a simple formula in the destination cell such as :-
=Sheet1!A1&","&Sheet1!A2&","&Sheet1!A3....Etc
However if the cell range fluctuates in size it would be easier to use a macro to copy the values.
Sub MergeCellValues ()
'Declare Variable
Dim rngTestCell as Range
Dim strNewCell as String
'Activate Source Worksheet
Thisworkbook.Sheets(1).Activate
Range("A1").Select
'Test for more than One Value and step to end of List
If ActiveCell.Offset(1,0) <> "" Then Selection.End(xlDown).Select
'Concatenation Loop
For Each rngTestCell in Range("A1:A" & Activecell.Row)
' Add New Cell values & Delimiter
strNewCell = strNewCell & rngTestCell.Value & ","
Next rngTestCell
'Set new cell value stripping last delimiter
Thisworkbook.Sheets(2).Range("A1").Value=Left(strNewCell,Len(strNewCell)-1)
End Sub
by srobertson
Exactly how long does it take to get a question rated or answered.
Obviously the problem wasn't that serious to begin with.
by new graduate
by new graduate
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending