Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot Table Format Preservation PatK Excel Discussion (Misc queries) 1 January 30th 10 11:24 AM
Cell preservation or previous value. Paul Excel Worksheet Functions 0 July 20th 09 09:51 PM
Macro for Printing Only Displayed Data Jean M Excel Programming 0 November 10th 04 11:55 PM
Having a status bar (%completion) displayed while my macro runs I CAN FLY[_2_] Excel Programming 2 June 3rd 04 03:29 PM
Force macro security warning to be displayed Daniel Klann[_2_] Excel Programming 0 January 29th 04 04:35 AM


All times are GMT +1. The time now is 03:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"