|
Sub 删除空白列代码() Application.ScreenUpdating = False For i = 1 To 50 '删除第一行“剩余课时”列 If Cells(1, i) = "剩余课时" Then Columns(i).Delete End If Next '删除“剩余课时列代码结束
Dim iC&, x& iC = Cells(1, 256).End(xlToLeft).Column For x = iC To 1 Step -1 If Cells(3, x) = "" And Cells(4, x) = "" And Cells(5, x) = "" And Cells(6, x) = "" And Cells(7, x) = "" And Cells(4, x) = "" And Cells(5, x) = "" And Cells(8, x) = "" And Cells(9, x) = "" And Cells(10, x) = "" And Cells(11, x) = "" And Cells(12, x) = "" And Cells(13, x) = "" And Cells(14, x) = "" And Cells(15, x) = "" And Cells(16, x) = "" And Cells(17, x) = "" And Cells(18, x) = "" Then Columns(x).Delete Next x For j = 1 To 40 '寻找“已上课时”列的循环 If Cells(1, j) = "已上课时" Then ii = Range("A65536").End(xlUp).Row() + 1 '定位到A列最后一行的下一行,ii For iii = 3 To Range("A65536").End(xlUp).Row() Cells(ii, j - 1) = "合计:" Cells(ii, j).Value = Application.WorksheetFunction.Sum(Range(Cells(2, j), Cells(iii, j))) '列汇总 Next End If Next Application.ScreenUpdating = True End Sub
Cells(ii, j).Value = Application.WorksheetFunction.Sum(Range(Cells(2, j), Cells(iii, j))) '列汇总 这句是汇总变量J列的代码,也要给iii赋值: For iii = 3 To Range("A65536").End(xlUp).Row()
|