I have some calculated values that depend on a selected range. I want to format these calculated values with the NumberFormat of the selected range. I'm assuming they all have the same NumberFormat so I just take the numberformat of the first cell.
I am currently using the NumberFormat as follows:
columnFormat = cell.NumberFormat
stringNum = cstr(format(doubleNum, columnFormat)
Unfortunately, it doesn't work in a lot of cases, like when the format is "General" or a rather complex one we use that works fine in the cell but shows positive numbers ending with a "_)".
Is there a more robust way to do this? Do I have to have a big list of exceptions to check for?
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.