ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA decimal places (https://www.excelbanter.com/excel-programming/320434-vba-decimal-places.html)

ALEX

VBA decimal places
 
Dear Excel Helper

In an Excel workbook I have a worksheet and a chart.

In the worksheet in cell P1 I have worked out a value as a percentage. I
have this displayed on my chart by using the folowing within my VBA code...

ActiveChart.Shapes("Text Box 13").Select
Selection.Characters.Text = Sheets("ComboBoxRef").Range("$P$1")

Now, the problem is as follows. On my worksheet, cell P1 is formatted to
display just two decimal places i.e. it displays as 6.3. However, on my chart
it displays as 6.32203200179032. How can I get it displayed as two decimal
places on my chart?

I have tried formatting the cell P1 but it makes no difference regaring what
is displayed. It is as if VBA only displays the 'underlying' value. I have
messed about with...

application.worksheetfunction.fixed(P1,2)

and...

numberformat= "0.0"

but it seems unsatisfactory.

If there is an easy way around this please let me know.

Best Regards

Alex

Tom Ogilvy

VBA decimal places
 
ActiveChart.Shapes("Text Box 13").Select
Selection.Characters.Text = _
Sheets("ComboBoxRef").Range("$P$1"),Text

--
Regards,
Tom Ogilvy


"Alex" wrote in message
...
Dear Excel Helper

In an Excel workbook I have a worksheet and a chart.

In the worksheet in cell P1 I have worked out a value as a percentage. I
have this displayed on my chart by using the folowing within my VBA

code...

ActiveChart.Shapes("Text Box 13").Select
Selection.Characters.Text = Sheets("ComboBoxRef").Range("$P$1")

Now, the problem is as follows. On my worksheet, cell P1 is formatted to
display just two decimal places i.e. it displays as 6.3. However, on my

chart
it displays as 6.32203200179032. How can I get it displayed as two decimal
places on my chart?

I have tried formatting the cell P1 but it makes no difference regaring

what
is displayed. It is as if VBA only displays the 'underlying' value. I have
messed about with...

application.worksheetfunction.fixed(P1,2)

and...

numberformat= "0.0"

but it seems unsatisfactory.

If there is an easy way around this please let me know.

Best Regards

Alex




ALEX

VBA decimal places
 
Tom

Thanks for that help. It works well.

Alex

"Tom Ogilvy" wrote:

ActiveChart.Shapes("Text Box 13").Select
Selection.Characters.Text = _
Sheets("ComboBoxRef").Range("$P$1"),Text

--
Regards,
Tom Ogilvy


"Alex" wrote in message
...
Dear Excel Helper

In an Excel workbook I have a worksheet and a chart.

In the worksheet in cell P1 I have worked out a value as a percentage. I
have this displayed on my chart by using the folowing within my VBA

code...

ActiveChart.Shapes("Text Box 13").Select
Selection.Characters.Text = Sheets("ComboBoxRef").Range("$P$1")

Now, the problem is as follows. On my worksheet, cell P1 is formatted to
display just two decimal places i.e. it displays as 6.3. However, on my

chart
it displays as 6.32203200179032. How can I get it displayed as two decimal
places on my chart?

I have tried formatting the cell P1 but it makes no difference regaring

what
is displayed. It is as if VBA only displays the 'underlying' value. I have
messed about with...

application.worksheetfunction.fixed(P1,2)

and...

numberformat= "0.0"

but it seems unsatisfactory.

If there is an easy way around this please let me know.

Best Regards

Alex






All times are GMT +1. The time now is 05:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com