[FONT="Consolas"][SIZE="2"][COLOR="Navy"]Option Explicit
Sub PrepareActuals()
Dim iActualsStartCol As Integer, _
iActualsEndCol As Integer, _
iVolStartCol As Integer, _
iBudgetStartCol As Integer
Dim lLastRow As Long, _
lFirstRefRow As Long, _
lLastRefRow As Long
Dim sFormula As String
Dim rProcess As Range, rCell As Range
[COLOR="Green"] '*
'* Define required data block boundries and[/COLOR]
iVolStartCol = 4
iBudgetStartCol = Range("A11").End(xlToRight).End(xlToRight).Column
iActualsStartCol = Cells(11, Columns.Count).End(xlToLeft).End(xlToLeft).Column
iActualsEndCol = Cells(11, Columns.Count).End(xlToLeft).Column
lLastRow = Range("C" & Rows.Count).End(xlUp).Row
[COLOR="Green"] '*
'* Fill table Actuals with formulae[/COLOR]
Application.ScreenUpdating = False
Set rProcess = Range("A11:A" & lLastRow)
Set rCell = rProcess.Find(what:="*")
Do While rCell.Address(False, False) <> "A11"
lFirstRefRow = rCell.Row
Set rCell = rProcess.FindNext(rCell)
lLastRefRow = rCell.Row - 1
If lLastRefRow < lFirstRefRow Then [COLOR="Green"]'* Search wrapped around[/COLOR]
lLastRefRow = lLastRow
End If
sFormula = "=" & Cells(lFirstRefRow, iVolStartCol).Address(False, False) _
& "/" & Cells(lFirstRefRow, iVolStartCol).Address(True, False) _
& "*" & Cells(lFirstRefRow, iBudgetStartCol).Address(True, False)
With Range(Cells(lFirstRefRow, iActualsStartCol), Cells(lLastRefRow, iActualsEndCol))
.Formula = sFormula
.Font.Bold = False
.Rows(1).Font.Bold = True
End With
Loop
Application.ScreenUpdating = True
[COLOR="Green"] '*
'* Clean-up[/COLOR]
Set rCell = Nothing
Set rProcess = Nothing
End Sub[/COLOR][/SIZE][/FONT]