![]() |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 09:56 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com