PDA

View Full Version : Copy - Do Procedure - Paste



Doctor P
05-01-2006, 09:19 PM
I am trying to do what should be very simple.

I am trying to copy a range of cells to the clipboard, then delete the range, run some code to assess the impact this has had on dependent formulas, and the paste back the original text, values, and formulas.

I would expect the simplified code to look something like this.

Sub GOGO()
Selection.Copy
Selection.ClearContents
' Run my other code here
Selection.Paste ' Paste in original values, text and formulas.
End Sub

I do not think the GetFromClipboard, and PutInClipboard procedures will help me, am I wrong?

acw
05-01-2006, 09:50 PM
Hi

My thought would be that it would depend on the amount of processing, but you will probably lose the data from the clipboard. If you have a fixed number of cells, then it may pay to store those details in an array in the program, clear out the existing data, process, then restore the original data from the stored array.

HTH

Tony

mdmackillop
05-02-2006, 03:30 AM
From the sound of it, you might be best to paste immediately in a temporary location, then cut and paste back after your other code is run.
Regards
MD

Doctor P
05-02-2006, 04:56 AM
That is my temporary solution - to store the data in an array, however I may be required to store serveral thousand cells sometimes. I am able to paste manually from the toolbar - I must be able to do the same with VBA.

Norie
05-02-2006, 09:22 AM
Instead of Copy then ClearContents try using Cut.

Doctor P
05-03-2006, 12:34 AM
There is no difference between that and copy. I still have exactly the same problem. I want to be able to paste from the clipboard. I would really like to be able to paste the nth entry from the clipboard.

TonyJollans
05-03-2006, 03:08 AM
I think Malcolm is correct, but ...

Depending on what you're doing, could you use Scenarios rather than doing your own thing?