日记首页
|
列表
|
添加日记
|
管理登陆
标题:删除空白列代码,汇总变量J列
<p><br>Sub 删除空白列代码()<br>Application.ScreenUpdating = False<br> For i = 1 To 50 '删除第一行“剩余课时”列<br> If Cells(1, i) = "剩余课时" Then<br> Columns(i).Delete<br> End If<br> Next '删除“剩余课时列代码结束</p><p> Dim iC&, x&<br> iC = Cells(1, 256).End(xlToLeft).Column<br> For x = iC To 1 Step -1<br> 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</p><p>Next x</p><p>For j = 1 To 40 '寻找“已上课时”列的循环<br> If Cells(1, j) = "已上课时" Then<br> ii = Range("A65536").End(xlUp).Row() + 1 '定位到A列最后一行的下一行,ii<br> <br>For iii = 3 To Range("A65536").End(xlUp).Row()<br> Cells(ii, j - 1) = "合计:"<br> Cells(ii, j).Value = Application.WorksheetFunction.Sum(Range(Cells(2, j), Cells(iii, j))) '列汇总<br> <br> Next<br> End If<br> <br>Next<br>Application.ScreenUpdating = True<br>End Sub</p><p></p><p><hr><p></p><p> Cells(ii, j).Value = Application.WorksheetFunction.Sum(Range(Cells(2, j), Cells(iii, j))) '列汇总</p><p>这句是汇总变量J列的代码,也要给iii赋值:</p><p>For iii = 3 To Range("A65536").End(xlUp).Row()</p><p><br></p><p><br></p><hr>