PDA

View Full Version : Formatting via code



Odyrus
05-25-2011, 07:40 AM
Hello all,

I'm unsuccessfully trying to format the value of the cell in the following code snippet to a percentage and keep getting compile errors for my efforts.

= wks.Range("BQ50").Value
I've tried:
"BQ50","0%"
"BQ50, "Percent"
wks.Format.Range("BQ50","0%".value

Any help is appreciate!
Cheers!

mikerickson
05-25-2011, 07:46 AM
This should work
Range("BQ50").NumberFormat = "0.00 %"

Odyrus
05-25-2011, 07:54 AM
Thanks for the quick response!

That didn't seem to work? This is the entire line of the code:

ThisWorkbook.Worksheets("Sheet1").Cells(Rows.Count,"A").End(xlUp).Offset(1).Value _
= wks.Range("BQ50").Value

When I replace the .value with your solution I get a blank cell. Any thoughts?

Paul_Hossler
05-25-2011, 11:23 AM
Think you need to do it in 2 steps:


ThisWorkbook.Worksheets("Sheet1").Cells(Rows.Count,"A").End(xlUp).Offset(1).Value = wks.Range("BQ50").Value

ThisWorkbook.Worksheets("Sheet1").Cells(Rows.Count,"A").End(xlUp).Offset(1).NumberFormat = "0.00 %"



Paul