How to make a concatenated formula string calculate?

gravanoc

Active Member
Joined
Oct 20, 2015
Messages
346
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I create the following formula in VBA using concat operators:

VBA Code:
rvRng.Offset(0, 3).FormulaR1C1 = _
        "=""=IFERROR(SUM('RV #"" &[@[Account '#]] & "" - "" &[@[Unit Name]] & ""'!D:D), $0.00)"""
    rvRng.Offset(0, 3).Copy
    rvRng.Offset(0, 3).PasteSpecial xlPasteValues
    ' wksInventory.Calculate (this line doesn't do the trick, unfortunately)

If I click into the cell represented by rvRng.Offset(0, 3), then press F2 then press Enter, the formula will activate and calculate properly. I'm just trying to accomplish this using VBA. I considered SendKeys, but it is probably not reliable enough for this situation. Any ideas?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
The beginning of your formula looks funny to me:
Rich (BB code):
rvRng.Offset(0, 3).FormulaR1C1 ="=""=IFERROR...

Why do you have so many equals signs and double-quotes?
It looks to me like you might be entering the formula as text, which is why you have to go into it and press enter to convert it to a formula.

Typically, this formulas should begin like this:
Rich (BB code):
rvRng.Offset(0, 3).FormulaR1C1 ="=IFERROR...
which means you may also need to remove some double-quotes at other spots in your formula.

Typically, when I am doing something like this, what I do is turn on the Macro Recorder, and record myself entering an example of the formula that I want, then stopping the Macro Recorder.
Then, when you view the VBA code, this will show you the basic structure of the formula you need, and then you can edit it to make it more dynamic.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,528
Messages
6,120,065
Members
448,941
Latest member
AlphaRino

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