View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default Function program

If sub Calculate1 puts the formula in like this it will affect rows 2
through 250 only rather than going to the last row of data in column 2:

Range(Cells(8, 3), Cells(250, 3)).FormulaR1C1 = .....


--
Jim
"maperalia" wrote in message
...
Could you please help me with the following.
I have a program that works for the entire column 3 and column 4 starting
from row 8. I wonder if I can stop it in the row 250 and then start with
another calculation from row 305 using the same column 3 and column 4. I
need
to do this because in the cell R300E5 I will use the different value used
in
R5C3.

The program below will show you what I am taking about,however, I do not
know
how to make the different in variables.

Thanks in advance and I really appreciate your taking your time to helping
me in this matter.

Best regards.
Maperalia

Option Explicit
Public Sub Calculation1()
Dim eRow As Long
eRow = Cells(Rows.Count, 2).End(xlUp).Row
Range(Cells(8, 3), Cells(eRow, 3)).FormulaR1C1 =
"=IF(RC[-1]=0,"""",(100-(((R5C3-RC[-1])/R5C3)*100)))"
Range(Cells(8, 4), Cells(eRow, 4)).FormulaR1C1 =
"=IF(RC[-2]=0,"""",100-RC[-1])"
End Sub


Public Sub Calculation2()
Dim eRow As Long
eRow = Cells(Rows.Count, 2).End(xlUp).Row
Range(Cells(305, 3), Cells(eRow, 3)).FormulaR1C1 =
"=IF(RC[-1]=0,"""",(100-((( R300E5-RC[-1])/ R300E5)*100)))"
Range(Cells(305, 4), Cells(eRow, 4)).FormulaR1C1 =
"=IF(RC[-2]=0,"""",100-RC[-1])"
End Sub


Public Sub AllCalculations()
Calculation1
Calculation2
End Sub