capture cell number format with VBA

D

David

for example cell number format may be: "0.0%"
Can i detect the format with code?
I have a sheet with various cell formats
with Before double click
I want to convert the number in the cell to a string containing the number
with a text "symbol" added to the end of that string
Then return the number to it's original format with Round(), etc.
My code is working OK but, for example, i am getting 0.2333445 instead of 23%
Thanks
 
M

Mike H

david,

Like this

r = ActiveCell.NumberFormat

With regard to 0.2333445 that is 23% well nearly, it's a little bit over

mike
 
M

Mike H

Perhaps you mean this

myval = 0.2333445
p = Format(myval, ActiveCell.NumberFormat)
Debug.Print p

Mike
 
D

David

Thanks Mike
This was what i was looking for...
i typed Range("A1"). and scrolled down the longggg list
i was blindsighted looking for .format or similar
so, in the end this turns out to be an attitude problem
ah well, learning from experience
thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top