Reputation: 741
Why does the following code produce '100%' in my percentage-formatted cells(1,1)
Worksheets("Sheet1").cells(1,1).value = .05
EDIT: I made my question much simpler as the comments cleared up some of the confusion.
EDIT: I realized later that I accidentally changed my cells() value again to 100%. Because it happened at a particular place in my code, I thought it was some sort of rounding issue. My problem should be solved now :).
Upvotes: 1
Views: 102
Reputation: 630
You can do this easily by setting the percentage in the VBA - so:
if your variable 'mypercent' is 0.05.
Worksheets("Sheet1").cells(1,1).value = Format(myPercent, "0.00%")
Would display as 5.00% as expected.
I hope that helps
Upvotes: 2