I got this UDF from a Forum Guru here. And it has worked perfectly up til now. It seems the original version doesn’t handle numbers stored as Text. The IsNumeric line gives a “false positive” for numbers stored as text and tries to handle it.
The column field on the pivot table is “JobCode”. The data in this field is Numbers stored as text. When I run the function thru the debugger the “JobCode” is handled by the line
The result is “JobCode”, 402
Where I think it should be handled by the line
so the result would be “JobCode”, “402”
I attempted to fix the problem by replacing this
with this
If the Filter = “123” then it would concatenate the two strings and result in “1230” and then Filter.Value + ”0” would not = Filter.Value and it would be handled as a string.
On the other hand if some other Filter was 123, attempting to concatenate a string “0” to it would result in 123 and it would be handled as a Number .
When I run this it runs down to the line
And then starts over at the strFormula line and changes the strDataField from “CountofPeople” to “People”. “CountofPeople” is the field name and in the table is actually “Sum of CountofPeople”. The first time thru it uses the correct version “CountofPeople” and then kicks back to the beginning and changes to "People" and it runs thru the code fine and handles the numbers stored as text fine. But still results in an error due to the incorrect DataField. Any idea why that line is kicking the code back to the beginning?
Thanks
Bookmarks