manderson
08-11-2009, 09:45 AM
Is it possible to copy a string directly to the clipboard in an Excel VBA macro?
For example, I can copy the contents of a cell using a statement like:
Cells([Row],[Col]).Copy
but I have generated a string by concatenating the contents of several cells:
myString = ""
For Each myCell In mySelection
myString = myString + CStr(myCell.Value) + ","
Next
and I want to copy that directly to the clipboard without inserting it in a cell first. I want to be able to past the result direcly into a text editor without going back into Excel, and the source spreadsheet should remain unmodified.
Any help would be much appreciated.
For example, I can copy the contents of a cell using a statement like:
Cells([Row],[Col]).Copy
but I have generated a string by concatenating the contents of several cells:
myString = ""
For Each myCell In mySelection
myString = myString + CStr(myCell.Value) + ","
Next
and I want to copy that directly to the clipboard without inserting it in a cell first. I want to be able to past the result direcly into a text editor without going back into Excel, and the source spreadsheet should remain unmodified.
Any help would be much appreciated.