difference between range.text and range.value

S

Sean Farrow

Hi;
could somebody please explain the difference between rang.text and
range.value? When should I use both?
Chers
Sean.
 
S

Sean Farrow

Chers, are there situations where I should use one and not the other?
Cheers
Sean.
 
P

Per Jessen

I never use .Text, and I don't think anyone in this group ever use it.

..Value can be used for all purposes.

Regards,
Per
 
W

ward376

I haven't found any examples of different results when reading a cells
content with one or the other. The data types and characters returned
have been the same in my experience. Really, the only difference I've
ever found is that you can write with .value...

Cliff Edwards
 
R

Rick Rothstein

See the help file example for the Text property of the Range object (put
text cursor on word Range, press F1, select Text from the Property drop
down).
 
J

Jim Cone

Also...
..Text is what is displayed in the cell and
..Value is actually what is contained in the cell except when it isn't.
(.Formula and .Value2 are better choices sometimes)

An example: the cell.Value is 1.23456 but the cell.Text is 1.23 because
the cell is formatted as "0.00"
--
Jim Cone
Portland, Oregon USA



"Sean Farrow"
wrote in message
Hi;
could somebody please explain the difference between rang.text and
range.value? When should I use both?
Chers
Sean.
 
W

ward376

Much better explanation Jim - I almost exclusively work with extracted
data and hadn't come across the formatting issue when reading cell
contents.

Thanks!
Cliff Edwards
 
C

Chip Pearson

Range.Value returns the underlying value of a cell, regardless of how
that cell is formatted for output. Range.Text returns exactly what
appears in the cell. For example, if A1 contains the number 987.1234
and is formatted for 2 decimal places, A1.Value would return 987.1234
while A1.Text would return 987.12. The Text property is read-only, so
you cannot assign a value to it. It is the Value transformed by
NumberFormat to display in the cell.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
D

Dave Peterson

Neither of those statements is true.

..Text has its own purpose and there are many in this newsgroup who use it
effectively.
 
W

ward376

I just found a difference (probably not a surprise to other
responders) but when reading cell values, range.text is limited to
1024 characters. Just had a cell with 6400+ characters (a distribution
list) and the len of range.text was 1024! Used range.value to get the
entire string into a variable.

Cliff Edwards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top