5,139
社区成员
发帖
与我相关
我的任务
分享
Sub TestSum(ByVal sCol As String, ByVal eCol As String, ByVal sRow As Long, ByVal eRow As Long)
On Error Resume Next
Dim i As Long
Dim Sht As Worksheet
Set Sht = ActiveSheet
With Sht
For i = .Range(sCol & "1").Column To .Range(eCol & "1").Column
.Cells(eRow + 1, i).Formula = "=sum(" & .Cells(sRow, i).Address(1, 1) & ":" & .Cells(eRow, i).Address(1, 1) & ")"
Next
End With
End Sub
Sub Test()
TestSum "B", "G", 10, 15
End Sub
//获取单元格值
值 = Worksheets("工作簿名称").Cells(行索引,列索引).Value
//给单元格赋值
Worksheets("工作簿名称").Cells(行索引,列索引).Value = 值 //行索引、列索引从1开始