I've tested both the suggestions above with Excel 2003, on a computer with standard system settings for Brazil:
Application.DecimalSeparator
always returns the character in the textbox for Decimal separator of the International tab of the Options form (regardless of whether the box for use system separators is checked or not).
Application.International(xlDecimalSeparator)
returns the system wide decimal separator.
I have found this to be very important when working with code to modify formulas (range.formula), in which the decimal separator must always be ".", and not the system wide decimal separator. Here's some illustrative code:
Sub formula_edit()
Dim str_formula As String, block_formula As String, str_address As String
Dim str_value As String, str_10 As String, str_value_dot As String
Dim str_formula_1 As String, str_formula_2 As String
If Application.UseSystemSeparators Then
str_10 = Application.International(xlDecimalSeparator)
Else
str_10 = Application.DecimalSeparator
End If
With ThisWorkbook.ActiveSheet
With Selection
str_formula = .Formula
str_address = .Cells(1, 0).Address(rowabsolute:=False, columnabsolute:=False)
str_value = CStr(.Cells(1, 0).Value)
str_value_dot = Replace(str_value, str_10, ".")
str_formula_1 = Replace(str_formula, str_address, str_value)
str_formula_2 = Replace(str_formula, str_address, str_value_dot)
End With
block_formula = "x" & str_formula
With .Range("A6")
On Error Resume Next
.Cells(1, 5).Value = "test failed"
.Cells(2, 5).Value = "test failed"
' precede with "x" to block formula evaluation on spreadsheet
.Cells(1, 1).Value = "x" & str_formula
.Cells(1, 2).Value = "x" & str_address
.Cells(1, 3).Value = "x" & str_value
.Cells(1, 4).Value = "x" & str_formula_1
.Cells(1, 5).Formula = str_formula_1
.Cells(2, 3).Value = "x" & Replace(str_value, str_10, ".")
.Cells(2, 4).Value = "x" & str_formula_2
.Cells(2, 5).Formula = str_formula_2
End With
End With
End Sub
With use system separators checked, and "." in the decimal separator box, I placed the value 2,36 ("," is my local system decimal separator) in cell D3, and the formula =D3*5,42 in cell E3. I then selected cell E3 and ran the macro above. Upon completion the contents of the cells were:
So for me:
Application.DecimalSeparator

Application.International(xlDecimalSeparator)

Sincerely,
Richard.
Bookmarks