Is it possible to paste something without first copying

wroze27

New Member
Joined
Apr 23, 2021
Messages
16
Office Version
  1. 2019
Platform
  1. Windows
Background:
I want to clear up an excel document for my boss and there is a formula that gets copied and pasted into many other cells across the document. Right now I have a block of cells marked off with the formula inside to use as a reference to copy and paste. I think the sheet would look cleaner if I could remove that reference and just have the formula pasted from the VBA.
My question: Is there a way to paste something without needing to copy first? Can you just write the cell's text/formula that will get pasted in the code itself?

Thanks for your help, I'm new to this side of Excel and getting better everyday
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
12,926
Office Version
  1. 365
Platform
  1. Windows
You can use something on the lines of Worksheets("Sheet1").Range("A1:B10").Formula ="your formula" to enter "your formula" into the sheet and range specified, however it is not quite so simple in reality. There are differences in the way that the formula needs to be written. Any text double quotes in the formula need to be duplicated, for example "text" becomes ""text"". If your formula uses relative references that need to adjust based on where it is entered then you will need to use FormulaR1C1 with R1C1 references.

There may be other things to take into consideration depending on the actual formula(s).
 

wroze27

New Member
Joined
Apr 23, 2021
Messages
16
Office Version
  1. 2019
Platform
  1. Windows
You can use something on the lines of Worksheets("Sheet1").Range("A1:B10").Formula ="your formula" to enter "your formula" into the sheet and range specified, however it is not quite so simple in reality. There are differences in the way that the formula needs to be written. Any text double quotes in the formula need to be duplicated, for example "text" becomes ""text"". If your formula uses relative references that need to adjust based on where it is entered then you will need to use FormulaR1C1 with R1C1 references.

There may be other things to take into consideration depending on the actual formula(s).
Can you explain to me why Worksheets("Sheet1").Range("R5").FormulaR1C1 = "=IF(R[0]C[-2]="""","""",R[0]C[-15]))" [/CODE] isn't working?
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
37,036
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
It looks like you have an extra closing parenthesis at the end of your formula.
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,132,914
Messages
5,655,937
Members
418,253
Latest member
TheJackal26

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
Top