Solved

How to Get Cell Format type?

Posted on 2004-09-13
8
587 Views
Last Modified: 2012-06-22
Hi..

I am setting data type for the cells by

cellRightClick>>Selct Format cell>Select Number Tab>>Select data Type

How to I retrieve the type which I assigned for the cells..

e.g : if  I assigned

cell>>RightClick>>Format cell

cells(1,1) = "General"
cells(2,1) = "Number"
cells(3,1) = "Date"
cells(4,1) = "Currency"

How to I get retreived the Data type which I assigned thru wizard..

bye
0
Comment
Question by:ps_velan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
8 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 20 total points
ID: 12044201
Hi ps_velan,
The TYPE function returns the data type:
=TYPE(A1)      returns 1 for numeric, 2 for text, 4 for logical, 8 for formula, 16 for error, 64 for array

The CELL function returns the format:
=CELL("format",A1)         There are numerous return values--see the on-line help for their meaning

Cheers!

Brad
0
 
LVL 81

Expert Comment

by:byundt
ID: 12049554
ps_velan,
Here are the possible return values from =CELL("format",A1). This information is taken from the on-line Help. The value on the left is the Data type you assigned with the wizard; the value on the right is what the CELL function returns for that data type.

General "G"
0 "F0"
#,##0 ",0"
0.00 "F2"
#,##0.00 ",2"
$#,##0_);($#,##0) "C0"
$#,##0_);[Red]($#,##0) "C0-"
$#,##0.00_);($#,##0.00) "C2"
$#,##0.00_);[Red]($#,##0.00) "C2-"
0% "P0"
0.00% "P2"
0.00E+00 "S2"
# ?/? or # ??/?? "G"
m/d/yy or m/d/yy h:mm or mm/dd/yy "D4"
d-mmm-yy or dd-mmm-yy "D1"
d-mmm or dd-mmm "D2"
mmm-yy "D3"
mm/dd "D5"
h:mm AM/PM "D7"
h:mm:ss AM/PM "D6"
h:mm "D9"
h:mm:ss "D8"

If the info_type argument in the CELL formula is "format", and if the cell is formatted later with a custom format, then you must recalculate the worksheet to update the CELL formula.

Brad
0
 
LVL 81

Expert Comment

by:byundt
ID: 13362358
Of course in VBA you can get similar information with ActiveCell.NumberFormat
0
 

Expert Comment

by:pj071397
ID: 21792967
How to use the =CELL("format",A1) funtion? sample code in vb.net
0
 
LVL 81

Expert Comment

by:byundt
ID: 21793807
pj,
You would be better off posting a new question regarding the use of CELL function in VB.Net. The only people seeing your comment here are the participants in this question--and I do not use VB.Net and am therefore unable to offer a suggestion.

Brad
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had the experience that you had to follow 10 steps over and over again every time when you need to nicely forward an important email to your manager? Fear no more! With the help of the Quick Steps feature in Outlook 2010, your old chor…
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question