Displaying cell contents

G

Gustaf

I wonder if it's possible when adding data to cells using VBA, to have one actual value (as seen in the Formula Bar) and another value that is displayed in the cell? I tried the Range.Value and Range.Text properties, but Range.Text won't work.

Range("D2").Value = "value"
Range("D2").Text = "text"

Row 2 gives error 424, object required. What kind of object does Text want?

Gustaf
 
J

Jim Rech

I think it wants the kind of object that can have its Text property changed.
For a range the Text property is read only.

You cannot have a different value in the cell than appears in the formula
bar, other than for number formatting. For example you could enter 1.234 in
a cell and number format it to show only 2 decimal places -> 1.23.

Taken to an extreme you could give the cell a custom number format like
"2222" which is what would always appear in the cell if any number is
entered.

You could also cover the cell with a text box and enter a different number
in it.

--
Jim
|I wonder if it's possible when adding data to cells using VBA, to have one
actual value (as seen in the Formula Bar) and another value that is
displayed in the cell? I tried the Range.Value and Range.Text properties,
but Range.Text won't work.
|
| Range("D2").Value = "value"
| Range("D2").Text = "text"
|
| Row 2 gives error 424, object required. What kind of object does Text
want?
|
| Gustaf
 

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