PasteSpecial - Comments and ColorIndex

J

JMay

Can I copy a cell (via Ctl-C) and then click on a destination, whether a
single cell or multiple cells - then activate a macro that will copy the
comments, the border and the color (from the source) to the destination
cell(s) without disturbing the value that is already in the destination
cell(s)?
Thks in advance...
 
P

Peter Atherton

This should do the trick

Sub CopyFormatComents()
'Assumes that range has been copied
If Application.CutCopyMode = xlCopy Then
Selection.PasteSpecial Paste:=xlPasteComments
Selection.PasteSpecial Paste:=xlFormats
Application.CutCopyMode = False
Else: MsgBox "You must copy a cell First"
End If

End Sub

Regards
Peter
 
J

JMay

I entered your Sub() but when I run it (after first doing a Copy, the
destination select - a single cell) ----- I get:
"You must copy a cell First" OK
We're almost there...
Thanks,
 
J

JMay

Peter, a quick note.... When I do a Step-through (with both windows on
screen) it works; but with my VBE closed, I'm getting the You must copy a
cell First" OK
Tks,
JMay
 
P

Peter Atherton

I've tried this again and it works OK for me. The message
is only to tell the user that he has not copied anything
to the clipboard before running the macro.

Copy the cell then select the destination cell and then
run the macro

Regards
Peter
 
D

Debra Dalgleish

When you choose Tools>Macro>Macros, CutCopyMode changes to False.
To run the macro, you could add a toolbar button, or assign a keyboard
shortcut.
 
J

JMay

That was the "prob"- Thanks to you both Peter and Debra
It works fine, now..
Most helpful..
JMay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top