ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   custom function-code for percentage (https://www.excelbanter.com/excel-discussion-misc-queries/29707-custom-function-code-percentage.html)

srinivasan

custom function-code for percentage
 
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


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,
--
Gary Brown

Please rate this posting if it is helpful to you.


"srinivasan" wrote:

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



All times are GMT +1. The time now is 05:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com