I am brand new to VBA and am running through some beginner examples. I have written the following code, but I was wondering how I could format how the number is presented in the msg box. Currently the msg box shows a percent with 7 decimal places. I would like 1 decimal place.
Since I am trying to learn, I would greatly appreciate an explanation with the code that will do it.
Thanks in advance for all your help!
Since I am trying to learn, I would greatly appreciate an explanation with the code that will do it.
Code:
Sub HighestPercent()
Maxpercent = 0
For Each theCell In Range("b2:b8")
If theCell.Value > Maxpercent Then
Maxpercent = theCell.Value
Name = theCell.Offset(0, -1).Value
End If
Next
MsgBox "The rep with the highest percent is " & Name & " with " & Maxpercent * 100 & "%"
End Sub