matthewlrx
New Member
- Joined
- Jul 4, 2022
- Messages
- 16
- Office Version
- 2021
- Platform
- Windows
Hi all
I have written the below code to work out what a percentage is of certain scores. The strange thing is the output box is showing the percentage wrong.
If i take the following:
Yes Responses: 118
No Responses: 10
Repeated Responses: 0
My formula to calculate percentage would be (Yes-Repeat)/(Yes+No)*100 and it should give me 92.19% but my vba gives me 1%.
What am I doing wrong here?
I have written the below code to work out what a percentage is of certain scores. The strange thing is the output box is showing the percentage wrong.
If i take the following:
Yes Responses: 118
No Responses: 10
Repeated Responses: 0
My formula to calculate percentage would be (Yes-Repeat)/(Yes+No)*100 and it should give me 92.19% but my vba gives me 1%.
What am I doing wrong here?
VBA Code:
Sub RAP()
Dim Yes As Variant
Yes = InputBox("How Many Yes's do you have", "RAP Calculator")
Dim No As Variant
No = InputBox("How Many No's do you have", "RAP Calculator")
Dim Repeat As Variant
Repeat = InputBox("How Many Repeat's do you have", "RAP Calculator")
Dim PRR As Variant
PRR = (Yes - Repeat)
Dim HMD As Variant
HMD = (Yes + No)
Dim RAP As Variant
RAP = (PRR / HMD) * 100
MsgBox "The Required Percentage is: " + Format(RAP, "0.00") + "%"
End Sub