FormulaLocal resulting in 1004 Run-time Error

radzdzij

New Member
Joined
Mar 8, 2007
Messages
12
I've been following Andrew Gould's VBA Introduction video series on YouTube and everything was running fine up till episode 11.2 - Application.InputBox

I type in Andrew's code letter-for-letter, you may compare it e.g. https://youtu.be/NvGv1n4TW28?t=1144

So when I type in the code I get 1004 Run-time error while in Andrew's video everything seems to run smoothly.

What gives?

Code:
 Sub EnterAFormula()

    Dim Myformula As String
    
    Myformula = Application.InputBox(Prompt:="Enter a formula", Type:=0)
    
    Range("G2").FormulaLocal = Myformula


End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try FormulaR1C1

Code:
Sub EnterAFormula()


    Dim Myformula As String
    
    Myformula = Application.InputBox(Prompt:="Enter a formula", Type:=0)
    
    Range("G2").FormulaR1C1 = Myformula
End Sub

For some reason the formula is coming back in RC format.
 
Upvote 0
Try FormulaR1C1

For some reason the formula is coming back in RC format.

Dante,
that has done it, thank you very much!

I do not understand however: it is indicated in Excel VBA help for Application.InputBox function:

If you use the InputBox method to ask the user for a formula, you must use the FormulaLocal property to assign the formula to a Range object. The input formula will be in the user's language.

And what is maybe even more interesting, on a different machine the code with FormulaLocal seemed to work just fine as I tested it there.

So I'm a bit confused. But your answer seems to have nailed it, so thank you very much again :-)
 
Upvote 0
Dante,
that has done it, thank you very much!

I do not understand however: it is indicated in Excel VBA help for Application.InputBox function:

If you use the InputBox method to ask the user for a formula, you must use the FormulaLocal property to assign the formula to a Range object. The input formula will be in the user's language.

And what is maybe even more interesting, on a different machine the code with FormulaLocal seemed to work just fine as I tested it there.

So I'm a bit confused. But your answer seems to have nailed it, so thank you very much again :-)

Even in the comments of the video other users had the same problem, it seemed a configuration of the language, but I checked my configuration and it is the same and I have the problem. Then we will have to try each machine.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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