PDA

View Full Version : Sum columns in table excel 2007



Jeff1959
03-22-2011, 06:39 PM
Hi all;
I'm trying to sum columns in a dynamic table. I have this code which works fine for a static range. What I would like to do is replace "B:N" with variables (fc and lc) but I can't seem to get the syntax right. Any suggestions will be welcomed,




Dim myA As Range
Dim fc As String
Dim lc As String



fc = ColumnLetter(FirstColumn + 1)
lc = ColumnLetter(LastColumn)


For Each myA In Columns("B:N").SpecialCells(xlCellTypeConstants, 23).Areas
myA.Cells(1, 1).Offset(myA.Rows.Count).Resize(1, myA.Columns.Count).Formula = _
"=SUM(" & myA.Columns(1).Address(False, False) & ")"
Next myA


thanks

fmcti
03-22-2011, 08:35 PM
Where comes the function ColumnLetter? It seems like your code is incomplete.