Using a Macro to Sum a Variable-Length Range (a Column)

  • Thread starter Thread starter Chuckles123
  • Start date Start date
C

Chuckles123

Dave,

Thanks for your help.

I used: Target.FormulaR1C1 = "=SUM(R3C:R[-1]C)",
which is very similar to your suggestion.

A corollary question -- I have a column of numbers (each cell contain
a number), with a fixed starting cell but a variable ending cell.
want the macro to assign a Name (Workbook definition) to this range.
Any ideas?

Chuckles12
 
Dim StartCell as Range
set StartCell = Range("B9")
range(StartCell,StartCell.End(xldown)).Name = "List1"


or

Sub Tester4()
Dim StartCell As Range
Set StartCell = Range("B9")
ThisWorkbook.Names.Add Name:="List1", RefersTo:= _
"=" & Range(StartCell, StartCell.End(xlDown)).Address(1, 1,
External:=True)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top