PDA

View Full Version : Solved: % problems



khalid79m
02-23-2010, 05:07 AM
'%

'YN
xRow = Workbooks(xFile).Sheets(Wks4).Cells(Cells.Rows.Count, "A").End(xlUp).Row
Workbooks(xFile).Sheets(Wks4).Range("E2:F" & xRow).NumberFormat = "0.000"
Workbooks(xFile).Sheets(Wks4).Range("E2:E" & xRow).FormulaR1C1 = "=IF(RC3="""","""",RC3/RC2)"
Workbooks(xFile).Sheets(Wks4).Range("F2:F" & xRow).FormulaR1C1 = "=IF(RC4="""","""",RC4/RC2)"

'YNF
Workbooks(xFile).Sheets(Wks4).Range("I2:I" & xRow).NumberFormat = "0.000"
Workbooks(xFile).Sheets(Wks4).Range("I2:I" & xRow).FormulaR1C1 = "=IF(RC8="""","""",RC8/RC7)"


'YN
xRow = Workbooks(xFile).Sheets(Wks4).Cells(Cells.Rows.Count, "K").End(xlUp).Row
Workbooks(xFile).Sheets(Wks4).Range("O2:P" & xRow).NumberFormat = "0.000"
Workbooks(xFile).Sheets(Wks4).Range("O2:O" & xRow).FormulaR1C1 = "=IF(RC13="""","""",RC13/RC12)"
Workbooks(xFile).Sheets(Wks4).Range("P2:P" & xRow).FormulaR1C1 = "=IF(RC14="""","""",RC14/RC12)"

'YNF
Workbooks(xFile).Sheets(Wks4).Range("S2:S" & xRow).NumberFormat = "0.000"
Workbooks(xFile).Sheets(Wks4).Range("S2:S" & xRow).FormulaR1C1 = "=IF(RC18="""","""",RC18/RC17)"

'Freeze

Workbooks(xFile).Sheets(Wks4).Range("A2:S" & xRow).Copy
Workbooks(xFile).Sheets(Wks4).Range("A2").PasteSpecial xlValues

'%
Workbooks(xFile).Sheets(Wks4).Range("E2:F" & xRow).Style = "Percent"
Workbooks(xFile).Sheets(Wks4).Range("I2:I" & xRow).Style = "Percent"
Workbooks(xFile).Sheets(Wks4).Range("O2:P" & xRow).Style = "Percent"
Workbooks(xFile).Sheets(Wks4).Range("S2:S" & xRow).Style = "Percent"


I run this code the first set gets the value as 0.00 format so for arguments sake say 0.60 , this I then convert to % so it should be 60% however sometimes it becomes 600% why is this ???

Bob Phillips
02-23-2010, 05:10 AM
Seems odd, it became 60% for me.

Can you post the workbook?

khalid79m
02-23-2010, 05:30 AM
SOLVED IT , i had a code removing zeros so where i had like 20 / 12 = x it was 2 / 12 hence not giving x.

How can I remove a 0 and not part of the value for exampl

20 should always equal 20
0 should by " "

but if i replace 0 with "" then 20 becomes a 2 and 0 becomes ""

help

tpoynton
02-23-2010, 07:09 AM
as Bob said, probably need a sample workbook. Why are you replacing 0's in the first place? Need to know how the 0's you want to remove are different from the ones you want to keep.