Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default capture cell number format with VBA

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default capture cell number format with VBA

david,

Like this

r = ActiveCell.NumberFormat

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

mike



"David" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default capture cell number format with VBA


Perhaps you mean this

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

Mike

"Mike H" wrote:

david,

Like this

r = ActiveCell.NumberFormat

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

mike



"David" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default capture cell number format with VBA

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


"Mike H" wrote:

david,

Like this

r = ActiveCell.NumberFormat

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

mike



"David" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Capture conditional format as cell format Diddy Excel Discussion (Misc queries) 2 June 23rd 09 11:01 PM
Capture a number from a cell containing numbers and letters Khurram Excel Programming 1 January 23rd 07 11:38 PM
Capture Col number davegb Excel Programming 6 June 1st 05 02:32 PM
Number format based on number format of another cell in another workbook Rob Excel Programming 9 January 9th 05 04:30 PM
How to capture row number Glen Mettler[_2_] Excel Programming 3 January 20th 04 06:24 PM


All times are GMT +1. The time now is 05:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"