ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Formating percentage in macro (https://www.excelbanter.com/excel-discussion-misc-queries/170055-formating-percentage-macro.html)

orquidea

Formating percentage in macro
 
Hi

In the below subprocedure I want to format Saskour20per with %. This result
Saskour20per will be placed in different cells depending of some if
conditions, therefore I can't set a Range("A1") for example.

Saskour20per = (saskour20 / sask20)
How could I do that.

Thanks in advance.
Orquidea

FSt1

Formating percentage in macro
 
hi
you didn't say how many cells or which cells so.......
format each cell you put it in......
Range("A1").Value = saskour20per
Range("A1").NumberFormat = "0.00%"
Range("B2").Value = saskour20per
Range("B2").NumberFormat = "0.00%"
Range("C3").Value = saskour20per
Range("C3").NumberFormat = "0.00%" each cell you put it in....
if you are working with variables just substitute the range address with
the variable.

REgards
FSt1

"orquidea" wrote:

Hi

In the below subprocedure I want to format Saskour20per with %. This result
Saskour20per will be placed in different cells depending of some if
conditions, therefore I can't set a Range("A1") for example.

Saskour20per = (saskour20 / sask20)
How could I do that.

Thanks in advance.
Orquidea


orquidea

Formating percentage in macro
 
Hi

Thanks for your answer. As I am working with variables I susbstituted the
range address with the variable but I get the error message "invalid
qualifier" and it highlights the underlined statement.

If sask20 < 0 Then
Saskour20per.Value = (saskour20 / sask20)
--------------------------
Saskour20per.NumberFormat = "0.00%"

Could you please tell me where I am making an error?

Thanks in advance
Orquidea

"FSt1" wrote:

hi
you didn't say how many cells or which cells so.......
format each cell you put it in......
Range("A1").Value = saskour20per
Range("A1").NumberFormat = "0.00%"
Range("B2").Value = saskour20per
Range("B2").NumberFormat = "0.00%"
Range("C3").Value = saskour20per
Range("C3").NumberFormat = "0.00%" each cell you put it in....
if you are working with variables just substitute the range address with
the variable.

REgards
FSt1

"orquidea" wrote:

Hi

In the below subprocedure I want to format Saskour20per with %. This result
Saskour20per will be placed in different cells depending of some if
conditions, therefore I can't set a Range("A1") for example.

Saskour20per = (saskour20 / sask20)
How could I do that.

Thanks in advance.
Orquidea



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

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