VB Converting Excel % Values to Decimal 
Author Message
 VB Converting Excel % Values to Decimal

I have a application acting as an interface for an excel spreadsheet. I have
values coming to text boxes from excel cells (using active x). Some cells
have % values in them, when I take them across to VB using

Text2.Text = XlSheet.Range("A20").Value

the % value is converted to a decimal so i.e. a value of 90% appears in the
text box as 0.9, the decimal equivilant of 90%. Ideally i need the string
"90%" to be returned but a string of "90" would be okay also. I've tried
using the data format property but this does no good. any ideas would be
cool.

cheers,
dave.



Sat, 08 May 2004 22:08:23 GMT  
 VB Converting Excel % Values to Decimal
I have a application acting as an interface for an excel spreadsheet. I have
values coming to text boxes from excel cells (using active x). Some cells
have % values in them, when I take them across to VB using

Text2.Text = XlSheet.Range("A20").Value

the % value is converted to a decimal so i.e. a value of 90% appears in the
text box as 0.9, the decimal equivilant of 90%. Ideally i need the string
"90%" to be returned but a string of "90" would be okay also. I've tried
using the data format property but this does no good. any ideas would be
cool.

cheers,
dave.



Sat, 08 May 2004 22:05:04 GMT  
 VB Converting Excel % Values to Decimal
Try using .Text instead of .Value

Shaddy
To email me, you must remove YOUR PANTS



Sat, 08 May 2004 22:25:15 GMT  
 VB Converting Excel % Values to Decimal
On Tue, 20 Nov 2001 14:05:04 -0000, "Dave Hammond"

Quote:

>I have a application acting as an interface for an excel spreadsheet. I have
>values coming to text boxes from excel cells (using active x). Some cells
>have % values in them, when I take them across to VB using

>Text2.Text = XlSheet.Range("A20").Value

>the % value is converted to a decimal so i.e. a value of 90% appears in the
>text box as 0.9, the decimal equivilant of 90%. Ideally i need the string
>"90%" to be returned but a string of "90" would be okay also. I've tried
>using the data format property but this does no good. any ideas would be
>cool.

>cheers,
>dave.

Change your code as follows:

Text2.Text = format(XlSheet.Range("A20").Value,"percent")

All numerical numbers are stored in a spreadsheet in their native
format.  What you see on the screen is all a matter of formatting.
Percentages are stored as a decimal and formatted as a percentage
within the spreadsheet.

Stuart Sutherland



Sun, 09 May 2004 03:24:52 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. values I input into Excel automatically go to a decimal value

2. How can I convert this Excel VB code to Access VB

3. Converting a 00:00:00 time to a decimal value

4. Convert time values into decimals

5. VB Excel Decimal Places

6. How can I change some values from decimal point to decimal comma

7. Storing Decimal Values versus Displaying Decimals ..

8. Converting Excel 5 macros to Excel 97 VB macros

9. Converting decimal to a day in Excel.

10. converting decimals into fractions in excel


 
Powered by phpBB® Forum Software © phpBB Group