davidjwest
davidjwest

Reputation: 546

VBA Macro Sum Variable Range

I need to add up the total for column L, I know the first and last rows:

lRow = Cells(Rows.Count, 2).End(xlUp).Row
fRow = Cells(lRow, "B").Value

So how do I use lRow and fRow in my SUM?

Upvotes: 1

Views: 2056

Answers (1)

Vityata
Vityata

Reputation: 43595

activecell.Formula = "=SUM(L" & lrow & ":L" & frow & ")"

Edit - Added:

Sub Assign
  dim dbl_assign as long

  lRow = Cells(Rows.Count, 2).End(xlUp).Row
  fRow = Cells(lRow, "B").Value

  activecell.Formula = "=SUM(L" & lrow & ":L" & frow & ")"

  dbl_assign = activecell.value

end sub

Upvotes: 3

Related Questions