fieldset{padding:10px;}
VBA怎么求逐行累积有千行效果如:第二列 第三列1 12 33 64 105 15——解决方案——————————————————–VB code
Dim strRange As String Dim nRow As Integer nRow = 1000 '自己判断看要计算多少行 自己赋值 strRange = "C2:C" & nRow Range("C2").Select ActiveCell.FormulaR1C1 = "=R[-1]C+RC[-1]" Range("C2").Select Selection.AutoFill Destination:=Range(strRange), Type:=xlFillDefault------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------简单,看这个:VB code
Sub Main() '填20行数据 Call SetFormula(20)End SubSub SetFormula(ByVal n&)' 入口参数:n ----- 到第几行截止' *** 从第一行开始,填到 B 、C 两列 ***' 要填到其它列,自己参考修改 Dim i& Cells(1, 2).Formula = 1 Cells(1, 3).Formula = 1 For i = 2 To n Cells(i, 2).Formula = "=R[-1]C+1" Cells(i, 3).Formula = "=RC[-1]+R[-1]C" NextEnd Sub------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------先填充最后一个单元格,反过来自动填充就可以了 (G16:G22) Range("G22").Select ActiveCell.FormulaR1C1 = "=SUM(R[-6]C[-1]:RC[-1])" Range("G22").Select Selection.AutoFill Destination:=Range("G16:G22"), Type:=xlFillDefault Range("G16:G22").Select只有一条路不能选择——那就是放弃的路;