Is it possible to paste something without first copying

wroze27

New Member
Joined
Apr 23, 2021
Messages
31
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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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).
 
Upvote 0
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?
 
Upvote 0
It looks like you have an extra closing parenthesis at the end of your formula.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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