A Double type variable does not have properties.
So .Value and .NumberFormat cannot be used with them.
However, .Value and .NumberFormat do apply to a range object (cells).
There is a "Format" function that will format strings or numbers, so this should work...
Dim strNum as String
strNum = Format(Saskour20per,"0.00%")
Msgbox strNum
For what it is worth: Paul Lomax in his book "VB & VBA in a Nutshell" states that
the "Format function is possibly the most complex single function in VB"
(try Format(Saskour20per,"Percent")
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)
"orquidea"
wrote in message
Hi Jim
Thanks for replying back.
The three variables are declared as Double. When I run the macro I get the
message "invalid qualifier" and it highlights the row underlined. I don't
get any result. If I take off the word ".Value" and run the macro again it
gives me the same error and hightlights the same variable at the next row.
Saskour20per.Value = (saskour20 / sask20)
---------------
Saskour20per.NumberFormat = "0.00%"
I tested the macro before with the below procedure and I got the result in
decimals. The calculations are correct.
If sask20 <> 0 Then
Saskour20per = (saskour20 / sask20)
End If
Thanks
Orquidea