Forum

Simple Copy and Pas...
 
Notifications
Clear all

Simple Copy and Paste Formula-Only Code

4 Posts
2 Users
0 Reactions
1,811 Views
(@paul_f)
Posts: 81
Estimable Member
Topic starter
 

Hello,

This should be very simple but I lack VBA experience. I recorded a macro and then looked at the code it produced but I thought there might be a simpler way to change what I have, below.

Here's a line of code in my workbook:
Range("B1").Value = Range("B2").Value

This copies B2's value to B1.

I want to change this to copy B2's formula only (non-VBA: PasteSpecial/Formula) to B1. How should I rewrite this line of code?

Paul

 
Posted : 06/08/2019 6:04 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Paul,

You can use this

Range("B2").Copy
Range("B1").PasteSpecial xlPasteFormulas
Application.CutCopyMode = False

Regards

Phil

 
Posted : 06/08/2019 10:59 pm
(@paul_f)
Posts: 81
Estimable Member
Topic starter
 

Thank you, Phil.

 
Posted : 10/08/2019 7:49 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

no worries 🙂

 
Posted : 11/08/2019 3:20 am
Share: