Can't enter formula from cell using vba

SVRouss

New Member
Joined
Sep 17, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi All,
There is a problem depicted below. There is a cell B6 with a formula (does not matter what is the formula, a formula in principle), which is shown in cell B7 using FORMULATEXT function. Cell B8 contains this formula in the macro format obtained using the macro recorder.
Now the problem:
  • If using direct mentioning of the formula in vba procedure (Buttons Direct and Direct 1 and the corresponding macros), cell B6 returns the required value regardless the function you use (Formula, FormulaR1C1, Value, etc.)
  • If using a reference to the cell containing the formula in the right format (Buttons InDirect and the corresponding macros), cell B6 returns the value of the referenced cell but does not transform it into formula regardless the function you use (Formula, FormulaR1C1, Value, etc.) and the form of the value (c.Value ot c.Text).
  • Remark: format of all cells is General.
So the question is, how to transform formulae stored in cells into formulae using vba?
Example.png
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

SVRouss

New Member
Joined
Sep 17, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Bingo! You need to store formula is direct format (ie, as =RC[-1]&"["&R[-1]C[-1]&"]"&VLOOKUP(R[-1]C,R[-5]C[-1]:R[-3]C,2,0) in this case), then x.FormulaR1C1 = c.Value works correctly.
 
Solution

Forum statistics

Threads
1,148,257
Messages
5,745,712
Members
423,969
Latest member
seanguerrero

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