Have you tried recording the macro using Ctrl+Shift+up to select the range? That should work in Excel 2000 or later. The code below should do it also
Dim strAddress As String
strAddress = Range(ActiveCell.Offset(-1, 0), ActiveCell.Offset(-1, 0).End(xlUp)).Address(False, False)
ActiveCell.Formula = "=sum(" & strAddress & ")"
Gary
Here is one way;
Note: You will have to have the active cell
below the column to autosum
Sub AutoSum()
CommandBars.FindControl(ID:=226).Execute
Application.SendKeys "~"
End Sub
Ivan
When I use the one starting with Sub AutoSum() I get an Expected Statement or End of Statement at the beginning.
When I use The one staring with Dim I get expected end of statement on the last line.
When I use the strl shift up it still does it relative.
Any ideas would be appreciated.
Hi --
I am amased at Ivans code works fine, multi select and i will add that to my toolkit poss the best 3 line cide ive seen.
Ok autosum can go up or rioght, but thats excel for you, but all i can suggest is custom function UDF, but thats pointless as has own already
All i can suggest is highlight the range and hit autosum button thus answer is one below.
HTH
PS Ivan.. cheers mate ill use that as i like it----- a lot, will develope in UDF poss, ill post if i do, have idea for it, cheers again