Solved

How to Get Cell Format type?

Posted on 2004-09-13
8
576 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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel 2010 question 3 54
Formatting Problem within Excel 3 51
Outlook 2016 hangs on the Launch Screen 3 59
Spell checking an unbound form in MS Access 2013 9 57
Problem: You created a new custom form in Outlook for your contacts (added fields, deleted fields, changed the layout of fields, whatever) and made it the default form for contacts. The good news is that all new contacts will utilize the new form. T…
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
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…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

911 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

17 Experts available now in Live!

Get 1:1 Help Now