![]() |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 03:54 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com