Range.FormulaArray localization issues

rdilipk

New Member
Joined
Nov 17, 2011
Messages
36
To get around the limitation that Range.FormulaArray cannot accept a formula more than 255 chars in length, I use this work around:

long_formula_part1 = "=ZZZ(""a"",""b"",""c"",""somekey=tick,tock,jog"",dummy"
long_formula_part2 = ",""e"",""f"",""g"")"
to_replace = ",dummy"
act_formula = "ABC"

Range r = ' some range in excel

With r
.formulaArray = long_formula_part1
.Replace to_replace, long_formula_part_2
'I do the following because I don't want the actual formula to fire until I am done replacing everything
'My actual formula is a User Defined function written in C++
.Replace "ZZZ", act_formula
End With

My problem happens when the regional settings is not English US. If I switch to Germany, it looks like the list separator is a ';' as opposed to ','. So lets say I do this instead:

long_formula_part1 = "=ZZZ(""a"";""b"";""c"";""somekey=tick,tock,jog"";dummy"
long_formula_part2 = ";""e"";""f"";""g"")"
to_replace = ";dummy"
act_formula = "ABC"

Range r = ' some range in excel

With r
.formulaArray = long_formula_part1
'NOTE: The following line promptly fails if the Replace function sees any *semi-colon* in either its
'first parameter or its second
.Replace to_replace, long_formula_part_2
.Replace "ZZZ", act_formula
End With

Is there a way out?
 
How painful is it to pass the entire array formula as a string to a function? How much simpler could it be?
Its not that. With my limited vba skills I find it a little difficult to follow that function. What is the 3rd parameter to it and how does it handle localized list separators?
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
How painful is it to pass the entire array formula as a string to a function? How much simpler could it be?
Another thing that is hard for me to arrange is your requirement that VBE cannot have focus when this function runs. All our VBA modules sit in a common .xla file and many developers simultaneously work on it with the VBE constantly in focus for debugging. Will this be a problem?
 
Upvote 0
The third argument is optional, and allows you to pass a format string if you want to set the cell formatting. Ignore it if you don't need it.

As to localization, I don't know; I've never used Excel configured for other than US settings.

The VBE can be open, it just can't have focus. If your developers can't manage that, then it would be a problem.
 
Upvote 0

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

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