PDA

View Full Version : How to copy two non-contiguous cells



YellowLabPro
10-02-2007, 04:38 AM
I want to copy this to the clipboard:
F7and F9
This line copies F7 through F9

Range("F9" & ",F7").Copy


thx

mdmackillop
10-02-2007, 05:27 AM
Range("F7,F9").Copy Range("J10")

Don't forget the Macro recorder!

YellowLabPro
10-02-2007, 06:33 AM
Good Day Malcolm,
Good point about the recorder.
But this is slightly different. Copying the non-contiguous cells to a sheet works fine, but not to the windows clipboard. It copies and pastes a contiguous range- F7, F8, & F9 to the windows clipboard.
So when I paste I get data from F8 I do not want in it.

The only way I have figured out how to handle this is:


Range("F7,F9").Copy Range("IV1")
Range("IV1").Cut
Range("IV1").Copy Range("IV3")
Range("IV1").Delete Shift:=xlShiftUp
Range("IV1:IV2").Copy

rory
10-02-2007, 06:43 AM
Doug,
Range("F7,F9").Copy works for me.

YellowLabPro
10-02-2007, 08:06 AM
Rory,
The copy works,
but paste it to a notepad file, you will see it pastes the contents of f7,f8, and f9, not just f7 and f9

rory
10-02-2007, 08:20 AM
Oh OK. Is that actually your destination?

YellowLabPro
10-02-2007, 08:36 AM
More or less.
Not to open a can of worms here, but it is to copy two email addresses to my email program send to field, so the clipboard is the copy to location.
SendMail method in VBA will only work up until a point w/ AOL.
I can either get the subjet or the send to address, but not both.
So I chose the subject.

rory
10-02-2007, 08:57 AM
Do you have Outlook? You can set that up to work with AOL's IMAP email.

YellowLabPro
10-02-2007, 09:04 AM
I do have Outlook.
You will have to give me some idea of IMAP.... and what is involved.
thanks for the extra help on this, being out of scope... ;-)

rory
10-02-2007, 09:15 AM
I don't have the details here, but they should be on the AOL website. It's not that hard to set up as I recall (been a while since I actually used my AOL account to send any email!)

mdmackillop
10-02-2007, 10:23 AM
Interesting Doug.
You can simplify your intermediate step a bit though
Range("E5, E9").Copy Range("IV1")
Range("IV1").CurrentRegion.Copy

YellowLabPro
10-02-2007, 04:46 PM
Thanks Malcolm,
sorry for the delay- did not get a notice anything had been updated. I just happened to check in...

cheers