preservation of displayed value in vb macro

G

Guest

I have a variable in a vb macro that grabs a number from a cell with
formatting applied as Number with 2 decimals. In the program, if a number
has zeros after the decimal, the variable is assigned the whole number. For
instance, 100.00 comes in as 100. If the number is displayed as 100.01, it
comes in as 100.01. I need to preserve the displayed decimal, and have that
value assigned to the variable instead of the stored value. Is there a way a
vb macro can grab the displayed value vs the stored value of a cell? J
 
J

Jim Rech

ActiveCell.Text

would do it but you must read this into a string variable. With a numeric
variable the ".00" will be dropped by VB just as Excel does it.

--
Jim
|I have a variable in a vb macro that grabs a number from a cell with
| formatting applied as Number with 2 decimals. In the program, if a number
| has zeros after the decimal, the variable is assigned the whole number.
For
| instance, 100.00 comes in as 100. If the number is displayed as 100.01,
it
| comes in as 100.01. I need to preserve the displayed decimal, and have
that
| value assigned to the variable instead of the stored value. Is there a
way a
| vb macro can grab the displayed value vs the stored value of a cell? J
 

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