View Full Version : Format Percentage Problem
doctortt
04-02-2011, 08:05 PM
Hi,
I have this cell on the worksheet named abc, and I changed the properties of this cell to percentage.
And, I have this code in VBA
Format(Range("abc"), “Percent”)
When I do a msgbox on the line above, I only see .10
Can someone tell me what the problem is?
doctortt
04-02-2011, 08:12 PM
fixed it
I changed it to "0%"
RonMcK
04-02-2011, 08:25 PM
Doctortt,
Here's what I found works:
Sub MyLittleSub()
Dim wb As Workbook, ws As Worksheet
Set wb = ActiveWorkbook
Set ws = ActiveSheet
With ws
.Range("abc").NumberFormat = "0.00%"
End With
End Sub
When my effort at coding doesn't work, I record a macro, in this case applying the Percent format to a cell containing 0.1 as the data.
Sub Macro1()
'
' Macro1 Macro
'
'
Selection.NumberFormat = "0.00%"
End Sub
Then, I adjust my code to use what I learned from the Macro, in this case setting NumberFormat = "0.00%" instead of "Percent".
I hope this helps.
Now that I've posted my reply, I see that you updated with your discovery, essentially what I found.
Cheers,
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.