Thread: Losing Quotes
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
mcescher mcescher is offline
external usenet poster
 
Posts: 24
Default Losing Quotes

Hi All,
I often have a need to create a list of quote encased, comma separated
values and generally they are in or can be created in Excel. So, I
created a macro to do the hard work for me, so I didn't have to create
formulas every time I wanted to do this.
I wrote the following code and it works fine except the very first
element loses the quotes. Perhaps I highlight:

Jan
Feb
Mar

I want to be able to paste “Jan”, “Feb”, “Mar”
but, it’s coming back as Jan, “Feb”, “Mar”
The debug.print statement works fine, but putting it on the clipboard
messes it up. Any suggestions?

Thanks!

Sub camBuildString()
''Take the highlighted range and make it into a list of comma
separated values
Dim strQt As String, strOut As String, cell As Range
strQt = """": strOut = ""
For Each cell In Application.Selection
If Not IsEmpty(cell.Value) Then
strOut = strOut & strQt & cell.Value & strQt & ", "
End If
Next
Debug.Print (Left(strOut, Len(strOut) - 2))
'PutOnClipboard (Left(strOut, Len(strOut) - 2))
PutOnClipboard strOut
End Sub