Solved

How to Get Cell Format type?

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

690 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