VBA宏和可变范围

时间:2016-09-28 10:28:44

标签: excel vba excel-vba

我需要将L列的总数加起来,我知道第一行和最后一行:

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

那么如何在我的SUM中使用lRowfRow

1 个答案:

答案 0 :(得分:3)

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

编辑 - 已添加:

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