capture cell number format with VBA

  • Thread starter Thread starter David
  • Start date Start date
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
 
david,

Like this

r = ActiveCell.NumberFormat

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

mike
 
Perhaps you mean this

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

Mike
 
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
 
Back
Top