Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
preservation of displayed value in vb macro
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
preservation of displayed value in vb macro
Only if you store it as a string
Dim sStr as String sStr = ActiveCell.Text -- Regards, Tom Ogilvy "jsons71" wrote in message ... 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
preservation of displayed value in vb macro
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 "jsons71" wrote in message ... |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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
preservation of displayed value in vb macro
thanks
"Jim Rech" wrote: 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 "jsons71" wrote in message ... |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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
preservation of displayed value in vb macro
thanks much
"Tom Ogilvy" wrote: Only if you store it as a string Dim sStr as String sStr = ActiveCell.Text -- Regards, Tom Ogilvy "jsons71" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Pivot Table Format Preservation | Excel Discussion (Misc queries) | |||
Cell preservation or previous value. | Excel Worksheet Functions | |||
Macro for Printing Only Displayed Data | Excel Programming | |||
Having a status bar (%completion) displayed while my macro runs | Excel Programming | |||
Force macro security warning to be displayed | Excel Programming |