formula from VBA not working

Nils_Junker

Board Regular
Joined
Jun 2, 2023
Messages
80
Office Version
  1. 365
Platform
  1. Windows
Hi everybody,

my VBA looks like this:
i.e.: table1Sheet.range("D221").Formula2 = "=INDIREKT(ADRESSE(193,VERGLEICH(Dashboard!$P$17,Tabelle1!D2:BD2,0)+3))"
now this brings up the error #NAME
(Formula2 because of the @ which would be added without it)

But if I put the formula in the sheet manually it works.
What is the problem here?
Thanks for your help!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Can you try putting your formula in a cell and then in the immediate window, print out the formula.
? Activecell.formula2
I am expecting it to give you the US / English version of what you are using
 
Upvote 0
I have changed the language on my computer and if this worked in the spreadsheet:
Excel Formula:
=INDIREKT(ADRESSE(193,VERGLEICH(Dashboard!$P$17,Tabelle1!D2:BD2,0)+3))
Then this should work in the code:
VBA Code:
table1Sheet.range("D221").Formula2Local = "=INDIREKT(ADRESSE(193,VERGLEICH(Dashboard!$P$17,Tabelle1!D2:BD2,0)+3))"
I am only repeating it here if you want to just try it again using copy/paste in case there were any typing errors.
 
Upvote 0
I have changed the language on my computer and if this worked in the spreadsheet:
Excel Formula:
=INDIREKT(ADRESSE(193,VERGLEICH(Dashboard!$P$17,Tabelle1!D2:BD2,0)+3))
Then this should work in the code:
VBA Code:
table1Sheet.range("D221").Formula2Local = "=INDIREKT(ADRESSE(193,VERGLEICH(Dashboard!$P$17,Tabelle1!D2:BD2,0)+3))"
I am only repeating it here if you want to just try it again using copy/paste in case there were any typing errors.
I really dont know what the problem is here.
I checked the typing several times but still get the error 1004.
Do you have any other Idea what the problem here could be.
Appreciate your help!
 
Upvote 0
Can you copy in the message box you get with the 1004 error and also confirm that when you hit debug it goes to that exact line in the code ?
(the error doesn't say the sheet is protected does it ?)
Did you try my post#4 to see what the US version of the formula is ?
 
Upvote 0
Do you normally use commas as the separator in a formula or semi-colons?
Maybe it should be
VBA Code:
table1Sheet.range("D221").Formula2Local = "=INDIREKT(ADRESSE(193;VERGLEICH(Dashboard!$P$17;Tabelle1!D2:BD2;0)+3))"
 
Upvote 0
Solution
I am signing off for the night. Fluff may have more of a time zone overlap with you.

As near as I can figure it the US equivalent would be:
(not sure if it also defaults to your default delimiter or not - @Fluff will probably know)
VBA Code:
table1Sheet.range("D221").Formula2 = "=INDIRECT(ADDRESS(193,MATCH(Dashboard!$P$17,D2:BD2,0)+3))"

Although something like this would seem to give you the same result:
VBA Code:
table1Sheet.range("D221").Formula2 = "=INDEX($A$1:$BD$219,193,MATCH(Dashboard!P17,A2:BD2,0))"
 
Upvote 0
Do you normally use commas as the separator in a formula or semi-colons?
Maybe it should be
VBA Code:
table1Sheet.range("D221").Formula2Local = "=INDIREKT(ADRESSE(193;VERGLEICH(Dashboard!$P$17;Tabelle1!D2:BD2;0)+3))"
in the excel sheet i have to use semi-colons but in the code i have to use commas
 
Upvote 0

Forum statistics

Threads
1,215,650
Messages
6,126,017
Members
449,280
Latest member
Miahr

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