日记首页
|
列表
|
添加日记
|
管理登陆
标题:vba,最后一行,写入单元格
<span class="ask-title">如何使用vba命令定位到最后一行有内容单元格的下一行。</span> <div class="wgt-best " id="best-answer-821049319"><div class="bd answer" id="answer-821049319"><div class="line content"><div class="best-text mb-10" id="best-content-821049319" accuse="aContent"><br></div><div class="best-text mb-10" accuse="aContent">i=range("A65536").end(xlup).row()+1</div><div class="best-text mb-10" accuse="aContent"><br>这个i就是A列你要的行号 <br>此代码只适用于excel 2003<br>如果是07以上<br>65536修改为1048576 </div><div class="best-text mb-10" accuse="aContent"><br></div><div class="replyask-box mb-15"><div class="replyask line replyask-ask" id="replyask-24788317"><div class="ask-supply-line"></div><div class="ask ask-supply f-12 grid">追问:那怎么定位那</div></div><div class="replyask line replyask-ans" id="replyask-24788446"><div class="ask-supply-line"></div><div class="reply ask-supply f-12 grid">追答:不懂你的定位是什么概念。<br><br>sub aa()<br>i=range("A65536").end(xlup).row()+1<br>range("A" & i).Select<br>msgbox "你需要的是A"& i<br>end sub</div><div class="reply ask-supply f-12 grid"><br></div><div class="reply ask-supply f-12 grid"><hr>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 '删除“剩余课时列代码结束</div><div class="reply ask-supply f-12 grid"> Dim iC&, x&<br> 'Columns("Am").Delete<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) = "" Then Columns(x).Delete<br> If Cells(3, x) = "" And Cells(4, x) = "" And Cells(5, x) = "" Then Columns(x).Delete</div><div class="reply ask-supply f-12 grid">Next x</div><div class="reply ask-supply f-12 grid">For j = 1 To 40 '寻找“已上课时”列的循环<br> If Cells(1, j) = "已上课时" Then<br> <br> ii = Range("A65536").End(xlUp).Row() + 1 '定位到A列最后一行的下一行,ii<br> Cells(ii, j - 1) = "合计:"</div><div class="reply ask-supply f-12 grid"> End If<br> Next '删除“剩余课时列代码结束</div><div class="reply ask-supply f-12 grid">Application.ScreenUpdating = True<br>End Sub</div></div></div></div></div></div>