Posted to microsoft.public.excel.programming
|
|
Function program
It is slightly different
I changed
Range(Cells(startRow, 4), Cells(eRow, 4)).FormulaR1C1 = _
to this
Range(Cells(startRow, 4), Cells(endRow, 4)).FormulaR1C1 = _
in 2 places
--
HTH
RP
(remove nothere from the email address if mailing direct)
"maperalia" wrote in message
...
Bob;
Thanks for your quick respond.
However, the program youjust sent me is exactly the previous one. I do not
see the changes.
Could please please verify it .
Thanks.
Maperalia
"Bob Phillips" wrote:
That looks like mine, I missed a variable. Try this
Option Explicit
Public Sub Calculation1(startRow, endRow)
Range(Cells(startRow, 3), Cells(endRow, 3)).FormulaR1C1 = _
"=IF(RC[-1]=0,"""",(100-(((R5C3-RC[-1])/R5C3)*100)))"
Range(Cells(startRow, 4), Cells(endRow, 4)).FormulaR1C1 = _
"=IF(RC[-2]=0,"""",100-RC[-1])"
End Sub
Public Sub Calculation2(startRow, endRow)
Range(Cells(startRow, 3), Cells(endRow, 3)).FormulaR1C1 = _
"=IF(RC[-1]=0,"""",(100-(((( R300E5-RC[-1])/ R300E5)*100)))"
Range(Cells(startRow, 4), Cells(endRow, 4)).FormulaR1C1 = _
"=IF(RC[-2]=0,"""",100-RC[-1])"
End Sub
Public Sub AllCalculations()
Calculation1 8, 250
Calculation2 305, Cells(Rows.Count, 2).End(xlUp).row
End Sub
--
HTH
RP
(remove nothere from the email address if mailing direct)
"maperalia" wrote in message
...
Gentlemen;
I really appreciate your giving this information.
However, when I run the program I got this window message:
Run-time error'1004'
Application-defined or object-defined error
After I click debug it is highlighting at:
Range(Cells(startRow, 3), Cells(endRow, 3)).FormulaR1C1 =
"=IF(RC[-1]=0,"""",(100-(((( R300E5-RC[-1])/ R300E5)*100)))"
Thanks in advance
Maperalia
The program is:
Option Explicit
Public Sub Calculation1(startRow, endRow)
Range(Cells(startRow, 3), Cells(endRow, 3)).FormulaR1C1 =
"=IF(RC[-1]=0,"""",(100-(((R5C3-RC[-1])/R5C3)*100)))"
Range(Cells(startRow, 4), Cells(250, 4)).FormulaR1C1 =
"=IF(RC[-2]=0,"""",100-RC[-1])"
End Sub
Public Sub Calculation2(startRow, endRow)
Dim eRow As Long
Range(Cells(startRow, 3), Cells(endRow, 3)).FormulaR1C1 =
"=IF(RC[-1]=0,"""",(100-(((( R300E5-RC[-1])/ R300E5)*100)))"
Range(Cells(startRow, 4), Cells(eRow, 4)).FormulaR1C1 =
"=IF(RC[-2]=0,"""",100-RC[-1])"
End Sub
Public Sub AllCalculations()
Calculation1 8, 250
Calculation2 305, Cells(Rows.Count, 2).End(xlUp).Row
End Sub
"hideki" wrote:
How about change to erow=250 in calculation1? If you use
erow=Cells(Rows.Count, 2).End(xlUp).Row it will go until the last
row.
--
hideki
------------------------------------------------------------------------
hideki's Profile:
http://www.excelforum.com/member.php...o&userid=18903
View this thread:
http://www.excelforum.com/showthread...hreadid=399482
|