View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Matt[_47_] Matt[_47_] is offline
external usenet poster
 
Posts: 4
Default Function or Macro for Variable Formula?

Found the solution myself:

Sub BlitzBeforeData()

Dim foundRow As Double
Dim foundColumn As Double
Dim lastRow As Long

Dim Count As Integer

Application.ScreenUpdating = False

lastRow = Cells(65000, 2).End(xlUp).Offset(0, 0).row

For Count = 2 To lastRow
Cells(Count, 11).Select

foundRow = Cells(Count, 8).Value
foundColumn = Cells(Count, 9).Value

ActiveCell.FormulaR1C1 = "=AVERAGE('[Workbook.xls]Sheet1'!R" & _
foundRow & "C" & (foundColumn - 13) & ":R" & foundRow & "C" &
(foundColumn - 1) & ")"

Next Count

Application.ScreenUpdating = True

End Sub