How to make a VBA Function return a value in percent format
On 3/10/2012 7:17 AM, John Black wrote:
Hi,
I've been searching google for a while on this question but I can't find anything. I wrote a
very simple function that returns the growth percentage between two numbers:
Function GP(Val1 As Double, Val2 As Double)
GP = (Val2 - Val1) / Val1
End Function
I would like the result to automatically be displayed in "%0.00" format but I cannot figure
out how to make that happen. Right now it returns a number like 0.45632 and I have to click
the cell and format it to percentage. Is this possible? Thanks.
John Black
Hi
Try
With GP
..NumberFormat = "0.00%"
End With
HTH
Mick.
|