ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formating of Numbers (https://www.excelbanter.com/excel-programming/322170-formating-numbers.html)

Bill[_28_]

Formating of Numbers
 
Hello,
Hope someone can help. I have a worksheet I use to generate a chart using
VBA code. I then want to label a series, for example, the average on the
chart using the number format on worksheet.

To find the number format, I use:

Formattype = cells(1,1).numberformat

Then I use something like

Avg. = format(x, formattype) to find the avg to put on the chart.

I get weird number formats like $1.28_ when I just use currency.

Any suggestions?

Thanks.

Bill




Juan Pablo González

Formating of Numbers
 
I think the easiest for you is to use the TEXT() worksheet function, instead
of the Format$() function, like this

Avg = Application.Text(x, formattype)

--
Regards

Juan Pablo González

"Bill" wrote in message
...
Hello,
Hope someone can help. I have a worksheet I use to generate a chart using
VBA code. I then want to label a series, for example, the average on the
chart using the number format on worksheet.

To find the number format, I use:

Formattype = cells(1,1).numberformat

Then I use something like

Avg. = format(x, formattype) to find the avg to put on the chart.

I get weird number formats like $1.28_ when I just use currency.

Any suggestions?

Thanks.

Bill






Bill[_28_]

Formating of Numbers
 
Thanks. Works like a charm.


"Juan Pablo González" wrote in message
...
I think the easiest for you is to use the TEXT() worksheet function,
instead
of the Format$() function, like this

Avg = Application.Text(x, formattype)

--
Regards

Juan Pablo González

"Bill" wrote in message
...
Hello,
Hope someone can help. I have a worksheet I use to generate a chart
using
VBA code. I then want to label a series, for example, the average on the
chart using the number format on worksheet.

To find the number format, I use:

Formattype = cells(1,1).numberformat

Then I use something like

Avg. = format(x, formattype) to find the avg to put on the chart.

I get weird number formats like $1.28_ when I just use currency.

Any suggestions?

Thanks.

Bill









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

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