-
Format Percentage Problem
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?
-
fixed it
I changed it to "0%"
-
Doctortt,
Here's what I found works:
[vba]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
[/vba]
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.
[vba]Sub Macro1()
'
' Macro1 Macro
'
'
Selection.NumberFormat = "0.00%"
End Sub
[/vba]
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,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules