Percentage type mismatch error handling

October 28, 2016 at 14:34:21
Specs: Windows 7
I have a macro that formats the value of a variable to percentage format. but sometimes instead of a number present in the cell it is sometimes a text string "N/A" (because there is no calculated score). When this happens I get a type mismatch because the macro is expecting a number to format. I'd like to write some code to catch this and allow the text string to pass through but if it is a number I'd like for it to continue as usual. The variables that I need this for are FeeString,QualityString, NPSString and RefSourceString. Can anyone help me write something like an If statement to handle this for all these variables?

NPS = NPSRng.Offset(0, 6).Value
Quality = QualityRng.Offset(0, 4).Value
Fee = FeeRng.Offset(0, 2).Value

RefSource = sourceRng.Offset(0, 7).Value
FormattedRefSource = Format(RefSource, "General Number")

FeeString = FormatPercent(Fee, 2)
QualityString = FormatPercent(Quality, 2)
NPSString = FormatPercent(NPS, 2)
RefSourceString = FormatPercent(RefSource, 2)


See More: Percentage type mismatch error handling

Report •

#1
October 28, 2016 at 23:26:43
How about a simple:

On Error Resume Next

Other options can be found (and explained) here:

http://www.cpearson.com/excel/error...

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •
Related Solutions


Ask Question