Solved

How to Get Cell Format type?

Posted on 2004-09-13
8
572 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
  • 4
8 Comments
 
LVL 80

Accepted Solution

by:
byundt earned 20 total points
Comment Utility
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 80

Expert Comment

by:byundt
Comment Utility
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 80

Expert Comment

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

Expert Comment

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

Expert Comment

by:byundt
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

How many times recently have you prepared a presentation or emailed a document to a client and you have found that they have older versions of MS Office and they can not open the file you have prepared.  Although most visitors to this site are exper…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now