When I run the function "LoadCurrencyStyles", the style format strings change to dollars, rupees, pounds etc.
To my mind this proves that my numeric-valued cells, formatted with appropriate styles ("Currency0", "Currency1" etc) can adapt to different locations.
I am happy.
I have a Worksheet_Change event:
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
If (Target.Row = 7) And (Target.Column = 2) Then
Dim strCurrencySymbol As String
strCurrencySymbol = Range("Currency").Value
Call LoadCurrencyStyles(ActiveSheet.Parent, strCurrencySymbol)
Else
End If
End Sub
It invokes the "LoadCurrencyStyles" function, and when I stop at the line "sty.NumberFormat = strStyleNumberFormat", the left-hand side of the assignment shows the old format (say, dollars) and the right-hand side shows the new format (say pounds).
I single-step through the assignment and re-check the two values.
To my horror/shame the left-hand side still shows the old format.
Something inhibits the assignment, but no error is produced in the running of the VBA.
Again, the slave code to change currencies works; I don't believe I am generating a syntactically-faulty format string.
It works perfectly, along with the Worksheet_Change event in four other workbooks.
But not in this one.
What is different?
This workbook has three user-defined functions that deliver values.
If I comment out the three functions, the currency format change is effected - perfectly!
But with the functions activated, they seem to inhibit execution of the assignment in the "LoadCurrencyStyles" function.
Why should a user-defined function cause execution of another piece of code to fail - but only on the assignment?
I would expect the VBA code to run NOT in parallel, that is, one of the two chunks of code should run, and then the other.
The user-defined functions are straightforward - a series of calculations on Double valued parameters producing a Double result.