Jennifer Murphy said:
As I tried to explain in my original post, I have
no trouble selecting the two non-adjacent columns.
It's what happens next that it the problem.
I think that was perfectly clear in your original posting. For anyone who
does not understand, all they need to do is try it. I reproduced the
problem with Office 2003 on WinXP.
2. If I select column B using the ctrl key [...]
and then select column J (again using the ctrl key),
I get an error when I try the Ctrl-C shortcut to copy
the data. The error is
"That command cannot be sued on multiple selections."
In my experiments, that depends on the alignment of the separate selections.
If I select parallel data (e.g. B1:B10 and J1:J10), the paste into Notepad
misbehaves exactly as you described initially, to wit: all the intervening
data is also copied unintentionally.
If I select non-parallel data (e.g. B1:B10 and J11:J20), I get the error
that you describe above when I try to copy. We don't even get to the paste
problem.
Note that in both cases, the selection is a collection of ranges. You can
see that using MsgBox Selection.Address in VBA.
My take on this is: there is no workaround, other than a macro that copies
the non-contiguous data for you. (And in that case, you need to decide and
specify exactly how the non-parallel example should be handled. I can think
of two ways to do, at least.)
Off-hand, I do not know how to copy just the selected data to the clipboard
just as if you had done it with ctrl-C; that is, so that ctrl-V in Notepad
does what you intended. A Google search reveals a couple of methods for
getting VBA data (in contrast to Excel data) into the clipboard. But I am
not familiar enough with the clipboard architecture to know all the
ins-and-outs.
If you would like to use such a macro, I suggest that you repost your
inquiry using the MS Answers Forums at
http://social.answers.microsoft.com/Forums/en-US/category/officeexcel. It's
not that I like that forum. It's just that MS has ceased to support the
Usenet newsgroups; see
http://www.microsoft.com/communities/newsgroups/default.mspx. Hence,
participation here is limited to the sites that share a common newsgroup
mirror, which is no longer centralized at MS. Many knowledgable Excel
experts no longer look at the newsgroups.