Inserted formula with VBA containing ''

mindsitch

New Member
Joined
Apr 22, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi, I am trying to insert a dynamic formula but for a reason I can't figure out in excel I get '' around the cell name. I have tried changing the cell format, variable type, making a separate variable and inserting as a whole. When I Debug.Print it shows normal. Any help would be great, I'll leave the code below. Thank you.

VBA Code:
Range("H"&insertCell).Formula = "=G" & insertCell & "*R4C11"

insertCell is an Integer being passed from another Sub and it's a possible range of numbers between 10-100
The result in the formula bar is : ='G17'*$K$4
I will also mention that the row is being created and after the formula is inserted along with other data.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi & welcome to MrExcel.
You are mixing A1 & R1C1 notation, which you shouldn't do. Try
VBA Code:
Range("H" & insertCell).FormulaR1C1 = "=R" & insertCell & "C7*R4C11"
 
Upvote 0
Solution
Hi & welcome to MrExcel.
You are mixing A1 & R1C1 notation, which you shouldn't do. Try
VBA Code:
Range("H" & insertCell).FormulaR1C1 = "=R" & insertCell & "C7*R4C11"
omg that worked, thank you a lot
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,838
Messages
6,121,885
Members
449,057
Latest member
Moo4247

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