求大神翻译
PrivateSubmySumTotal()Dimm,n,rAsIntegerSheets("Total").SelectRange("A2").SelectSelect...
Private Sub mySumTotal()
Dim m, n, r As Integer
Sheets("Total").Select
Range("A2").Select
Selection.CurrentRegion.Select
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1, Selection.Columns.Count).Select
Selection.Clear
Sheets("Index").Select
Range("A2").Select
MySheetNumber = Application.WorksheetFunction.CountA(Range("B:B")) - 1
m = 1: r = 2
Do Until m > MySheetNumber
MySheet = Sheets("Index").Range("B" & CStr(1 + m))
Sheets(MySheet).Activate
Range("A2").Select
n = Application.WorksheetFunction.CountA(Range("B:B"))
If n = 1 Then GoTo Halt:
Range("A2:D" & CStr(n)).Copy 'Union(Range("A2:D" & CStr(n)), Range("I2:I" & CStr(n))).Copy
Sheets("Total").Select
Range("A" & CStr(r)).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Halt: m = m + 1
If n = 1 Then
r = r
Else
r = r + n - 1
End If
Loop
Sheets("Total").Select
Range("A2").Select
End Sub
excel 宏 主要是求子表的总和 展开
Dim m, n, r As Integer
Sheets("Total").Select
Range("A2").Select
Selection.CurrentRegion.Select
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1, Selection.Columns.Count).Select
Selection.Clear
Sheets("Index").Select
Range("A2").Select
MySheetNumber = Application.WorksheetFunction.CountA(Range("B:B")) - 1
m = 1: r = 2
Do Until m > MySheetNumber
MySheet = Sheets("Index").Range("B" & CStr(1 + m))
Sheets(MySheet).Activate
Range("A2").Select
n = Application.WorksheetFunction.CountA(Range("B:B"))
If n = 1 Then GoTo Halt:
Range("A2:D" & CStr(n)).Copy 'Union(Range("A2:D" & CStr(n)), Range("I2:I" & CStr(n))).Copy
Sheets("Total").Select
Range("A" & CStr(r)).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Halt: m = m + 1
If n = 1 Then
r = r
Else
r = r + n - 1
End If
Loop
Sheets("Total").Select
Range("A2").Select
End Sub
excel 宏 主要是求子表的总和 展开
3个回答
展开全部
私人mySumTotal()暗淡M,N,R为整数表(“合计”),选择范围(“A2”)。选择“Selection.CurrentRegion.Select”Selection.Offset(1,0)。调整大小(Selection.Rows.Count - 1,Selection.Columns.Count)。选择Selection.Clear的表(“指数”)。选择范围(“A2”)。选择MySheetNumber= Application.WorksheetFunction.CountA(范围(“B:B”)) - 1米= 1:R =2DO直到M> MySheetNumber MySheet的表(“指数”)。范围(“B”CSTR(1+ M))表(MySheet的)。激活范围(“A2”)。选择N=应用。WorksheetFunction.CountA(范围(“B:B”))如果n=1,然后转到暂停:范围(“A2:D”CSTR(N))。复制'联盟(范围(“A2:D”CSTR(Ñ复印纸)),范围(“I2:”CSTR(N)))。(“合计”)。选择范围(“A”CSTR(R))。选择粘贴Selection.PasteSpecial:= xlValues操作:= xlNone SkipBlanks:=_假,移调:=假Application.CutCopyMode= FalseHalt:M= M+1如果n= 1,则R= R否则R = R + N - 1结束IfLoop的表(“合计”)。(“A2”)。选择结束小组
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询