Seven years ago The SilkCode provided this function to generate CSV within a cell from a range (post 986894)
I would like to enclose each list item, in the output of the function, in quotes [ CHR(34) ].
It's not difficult to paste the output into a text editor and running a replace operation but if I can avoid that operation it would be much quicker.
VBA Code:
Public Function RangeToCSV(targetRange As Range, Optional delimeter As String = ",") As String
Dim rowCounter As Long
Dim colCounter As Long
Dim targetArr() As Variant
Dim CSVStr As String
targetArr = targetRange
For rowCounter = 1 To UBound(targetArr, 1)
For colCounter = 1 To UBound(targetArr, 2)
CSVStr = CSVStr & IIf(CSVStr <> "", delimeter, "") & CStr(targetArr(rowCounter, colCounter))
Next
Next
RangeToCSV = CSVStr
End Function
I would like to enclose each list item, in the output of the function, in quotes [ CHR(34) ].
It's not difficult to paste the output into a text editor and running a replace operation but if I can avoid that operation it would be much quicker.