View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
ytayta555 ytayta555 is offline
external usenet poster
 
Posts: 247
Default Avoiding IF limits with VBA

HI

Here you have a example where all formulas work with
values of I8*I7 - I10 range , and put the result in range
from G10 to G21 :



Sub Macrocomanda6()
'
' Macrocomanda6 Macrocomanda
' Macrocomanda īnregistrata 07.03.2008 de ytayta
'

'
Range("G10").Select
ActiveCell.FormulaR1C1 = "=(R[-2]C[2]*R[-3]C[2])-RC[2]"
Range("G11").Select
ActiveCell.FormulaR1C1 = "=(R[-3]C[2]*R[-4]C[2])-R[-1]C[2]"
Range("G12").Select
ActiveCell.FormulaR1C1 = "=(R[-4]C[2]*R[-5]C[2])-R[-2]C[2]"
Range("G13").Select
ActiveCell.FormulaR1C1 = "=(R[-5]C[2]*R[-6]C[2])-R[-3]C[2]"
Range("G14").Select
ActiveCell.FormulaR1C1 = "=(R[-6]C[2]*R[-7]C[2])-R[-4]C[2]"
Range("G15").Select
ActiveCell.FormulaR1C1 = "=(R[-7]C[2]*R[-8]C[2])-R[-5]C[2]"
Range("G16").Select
ActiveCell.FormulaR1C1 = "=(R[-8]C[2]*R[-9]C[2])-R[-6]C[2]"
Range("G17").Select
ActiveCell.FormulaR1C1 = "=(R[-9]C[2]*R[-10]C[2])-R[-7]C[2]"
Range("G18").Select
ActiveCell.FormulaR1C1 = "=(R[-10]C[2]*R[-11]C[2])-R[-8]C[2]"
Range("G19").Select
ActiveCell.FormulaR1C1 = "=(R[-11]C[2]*R[-12]C[2])-R[-9]C[2]"
Range("G20").Select
ActiveCell.FormulaR1C1 = "=(R[-12]C[2]*R[-13]C[2])-R[-10]C[2]"
Range("G21").Select
ActiveCell.FormulaR1C1 = "=(R[-13]C[2]*R[-14]C[2])-R[-11]C[2]"


End Sub



The result is always in the G cell on that row, so for example it is
G10 for row 10 and G12 for row 12.



...here is a misunderstand , where you want macro to place the
results ...you said you want to have the result for every I10 ,K10,
M10 , O10.......AE10 cells ! How can put the 12 results in the same
cell ?


Respectfully

Hope to help