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 ???
'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 ???