Adding formulas by VBA; dealing with international keyboard differences

MarkLW

New Member
Joined
Aug 7, 2008
Messages
11
Hi. I'm scrapping some conditional formatting.

Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=AND(NOT(ISBLANK($AG3)),LEN($AG3)>12,Colors_On=TRUE)"

Code works just fine until found a coworkers that uses international / French keyboard and I found that "," needs to be ";" to work on that system when adding formula by script.

So I don't have to have multiple version thinking something like below but not sure what would go into custom function "KeyBoardType()"
If Keyboardtype = "US" Then
' Use ,
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=AND(NOT(ISBLANK($AG3)),LEN($AG3)>12,Colors_On=TRUE)"
Else
' Use ;
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=AND(NOT(ISBLANK($AG3));LEN($AG3)>12,Colors_On=TRUE)"
End if

Help with a 'KeyBoardType()' function or any other implementation suggestions would be great.

Thanks for the help.
 
This is the better solution, And I see no reason that it wouldn't work..
You just have to concatenate that character into the formula as needed.

I Like it.

I was doing a google on Excel International found
Code:
Application.International(xlListSeparator)

I should be able to insert this in line as part of my formula.
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
That is interesting because simply writing a formula with VBA then , will be converted to ; if necessary automatically

This may help

Code:
s = Application.International(xlDecimalSeparator)

Thank you got me in the direction I needed!
 
Upvote 0
This is the better solution, And I see no reason that it wouldn't work..
You just have to concatenate that character into the formula as needed.

Worked without issue on my system. Will find out next week how worked international. Thank you!
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,793
Members
451,589
Latest member
Harold14

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