title: Macro combining multiple cells into one, with values separated by a comma
body: <p>In a previous posted answer, <a href="https://stackoverflow.com/questions/2089756/combine-multiple-cells-into-one-in-excel-with-macro">Combine multiple cells into one in excel with macro?</a>, the following macro was provided..which works great by the way! </p>
  
  <p>However, I need to separate the cell values with a comma. I have tried inserting a comma between the quotes "," but this is not working. Can someone please guide me so the resulting cell will separate the values with a comma? Thank you!</p>
  
  <pre><code>Sub JoinCells()
  
  Set xJoinRange = Application.InputBox(prompt:="Highlight source cells to merge",     Type:=8)
  xSource = 0
  xSource = xJoinRange.Rows.Count
  xType = "rows"
  If xSource = 1 Then
  xSource = xJoinRange.Columns.Count
  xType = "columns"
  End If
  Set xDestination = Application.InputBox(prompt:="Highlight destination cell", Type:=8)
  If xType = "rows" Then
  temp = xJoinRange.Rows(1).Value
  For i = 2 To xSource
      temp = temp &amp; " " &amp; xJoinRange.Rows(i).Value
  Next i
  Else
  temp = xJoinRange.Columns(1).Value
  For i = 2 To xSource
      temp = temp &amp; " " &amp; xJoinRange.Columns(i).Value
  Next i
  End If
  
  xDestination.Value = temp
  
  End Sub
  </code></pre>