Sunday 10 June 2018

excel - Select String within Cell and Paste to Another Sheet



In Sheet1 cell A1 is the string "the cat sat on the mat". I can click into the cell and select "the cat" with my mouse and Ctr+C to copy it to the clipboard however...



I would like to be able to paste "the cat" into "Sheet2"A1 by using a short cut VBA.




I know that I can select an entire cell and paste into another sheet with a single VBA, but I can't seem to activate a Macro whilst I'm inside the cell and selecting "the cat".



Unless I'm wrong, I'm resigned to selecting "the cat", Copying via Ctr+C, clicking out of the cell and then activating a Macro - but please could someone tell me how to access the clipboard? When copying a selection of cells I use: Selection.Copy - how would I select the clipboard "the cat" that I've just copied?



Thanks in advance for any help


Answer



You're right, you can't run a macro while in Cell Edit mode. Once you've done your copy and clicked into the cell you're pasting in, you can just use:



Activecell.PasteSpecial


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...