Hi, mathmani,

sorry but I couldnīt find any code in your sample workbook...

Sub I_Hate_Merged_Cells()

Dim lngLast As Long
Dim rngMerged As Range

lngLast = Cells(Rows.Count, "A").End(xlUp).Row

Range("B1").Select

Do While ActiveCell.Value <> ""
  Set rngMerged = ActiveCell.MergeArea
  If rngMerged.Cells.Count > 0 Then
    Cells(lngLast, rngMerged.Cells(1).Column).Formula = "=SUM(" & Cells(2, rngMerged.Cells(1).Column).Address(0, 0) & ":" & _
        Cells(lngLast - 1, rngMerged.Cells(rngMerged.Cells.Count).Column).Address(0, 0) & ")"
  End If
  ActiveCell.Offset(0, 1).Select
Loop

End Sub
Ciao,
Holger