I'm not convinced Excel 2013 will not support UDF calls in conditional formatting formulas, for that I would like to see a test workbook.
UDF's are very sensitive to how they are programmed. A badly written UDF can break the calculation train, even when just called from worksheets cells.
Hence my question: what does the UDF look like. If you cannot share it, fair enough, but that also means we cannot troubleshoot the problem.
Hi
I guess this function is the one causing the problem, since it is calculated again and again without any change affecting the cells it is used in:
Function EngStrg2Number(EngStr As String, UnitStr As String) As Double
Dim Pos As Integer
Dim EngFactor As Double
Dim Prefix As String
EngStrg2Number = 0
While EngStrg2Number = 0 And Len(EngStr) > 0
Pos = InStrRev(EngStr, UnitStr, -1, 1)
If Pos > 1 Then
Prefix = Mid(EngStr, Pos - 1, 1)
Select Case Prefix
Case "P"
EngFactor = 1E+15
Case "T"
EngFactor = 1000000000#
Case "G"
EngFactor = 1000000000
Case "M"
EngFactor = 1000000
Case "k"
EngFactor = 1000
Case "d"
EngFactor = 0.1
Case "c"
EngFactor = 0.01
Case "m"
EngFactor = 0.001
Case "u"
EngFactor = 0.000001
Case "µ" 'Unicode U+00B5
EngFactor = 0.000001
Case "µ" 'Unicode U+03BC
EngFactor = 0.000001
Case "n"
EngFactor = 0.000000001
Case "p"
EngFactor = 0.000000000001
Case Else
EngFactor = 1
End Select
EngStrg2Number = Val(EngStr) * EngFactor
Else
EngStrg2Number = Val(EngStr) 'Error
End If
EngStr = Mid(EngStr, 2) 'Maybe there are characters at the start... kill them if it is really 0, it stays 0 until we killed the complete string
Wend
End Function
What the function does is quite obvious: it extracts a number from a string and includes "m" (=mili=1e-3), "n" (=nano=1e-9), "k"(=kilo=1e3) ... as a factor. IT also deletes leading characters, which confuse the "Val" function and return 0. Maybe I should
rather search for a RegExpression like
[0-9]+.?[0-9]*
for the number and then with another regular expression for the Unit and extract the character before it... That should be a more clean way, I guess? I am also nit sure about the two Micros (Greek and Science) which may or may not be used as input, whether
Excel really handles them differently?
@Jan Z: I guess I misunderstood you. I know now what you mean. As a workaround you could make a second sheet for each sheet and there fill in your
custom formula to determine whether the cell in the other sheet is locked and copy it all over the sheet and then refer with the conditional formatting to the other Sheet like:
=Sheet1_Formating!A1=True
Applied to $A$1:$AZ$99 in Sheet1
and then you should have the correct effect.
You could then also hide that sheet or even make a Macro to create such sheets and hide them...