custom function-code for percentage

S

srinivasan

I am new to VBA. However I have created a custom function using VBA and the
code is detailed below.

Public Function PLF(UnitsGenerated, PlantCapacity)
' This user defined function provides the PLF of the Plant in two decimals
PLF = (UnitsGenerated / PlantCapacity) * 8.76
PLF = Application.Round(PLF, 2)
End Function

The result of this custom function is shown in two digits. But I want a
percent symbol along with this result. Can anyone would suggest me the code
to be added for this for which I thank you in advance.

seenu
 
G

Gary Brown

Format the cell as a percentage and change your formula to...
PLF = Application.Round(PLF, 2)/100
or add a percentage sign to the formula...
PLF = Application.Round(PLF, 2) / 100 & "%"
HTH,
 
Top