tags:

views:

33

answers:

0

I'm trying to extend this formula and need some help I need to enter a sum fomula in row 3 of the new column created but don't know how to make it sum to a variable range to the left. and then I need to autofil the formula down to the end of the filled rows so that all the rows are calculated.

Sub AddColumns() Dim lastcol As Long, i As Long lastcol = Cells(1, Columns.Count).End(xlToLeft).Column

For i = lastcol To 1 Step -1

If InStr(1, Cells(1, i).Text, Application.Range("Current_Month").Value, vbTextCompare) Then Columns(i).Insert Columns(i).Select End If Next ActiveCell.Offset(0, 0).Select ActiveCell.Value = "Total Overdue" ActiveCell.Offset(2, 0).Select ' need to add a sum formula to this cell but number of cells in row depending on month in year 'need to autofil to end of occupied row