Any way to reduce Copy > Paste Formulas > Copy > Paste Values from 4 processes to 2?

d0rian

Active Member
Joined
May 30, 2015
Messages
313
Office Version
  1. 365
Silly Q, but a pattern that I use a lot in my file is copying a formula from a 'source' cell (e.g. A1) to a defined range (e.g. A2:A99), but since I want values A2:A99 to be hardcoded for file speed, I'll then Copy A2:A99 and paste_values A2:A99.

So the code ends up looking something like this:
Code:
Range("formula").[B]Copy[/B]
Range(Range("paste_range").Value).[B]PasteSpecial[/B] Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
Range(Range("paste_range").Value).[B]Copy[/B]
Range(Range("paste_range").Value).[B]PasteSpecial [/B]Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
Application.CutCopyMode = False

Is there a faster way to do that? Like some kind of paste function that in a single action tells Excel to paste the RESULT of the formulas rather than the formulas themselves?
 
Last edited:

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Please try below. I think you'll need two steps whatever approach you use.

Code:
With Range(Range("paste_range").Value)
    .FormulaR1C1 = Range("formula").FormulaR1C1
    .Value = .Value
End With
 
Upvote 0
Thanks, will try. Sounds like you're saying, though, that you wouldn't expect this method to be any faster than my original one, is that right?
 
Upvote 0
No. I'm saying you can't get away from the the two steps - formulas and then values. There won't be a one step paste function that does what you want in a single action.

Regarding speed, what I posted will (untested) be faster. How much I can't even guess. if you set up a loop & time doing hundreds of thousands of each approach it'd be interesting to learn.

regards

PS. I'm assuming the formula itself is fast. If it were some really slow array formula then the speed gain from the suggestion might seem less dramatic - with the bulk of the time being consumed by a slow formula calculation rather than the code execution. If that is the case, change the slow formula approach.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,952
Members
449,198
Latest member
MhammadishaqKhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top