[英]Delete a row starting at a specific row, Excel VBA
wsIMP.Columns(4).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
The code will delete everything in D that is an empty cell, which I want, is there a way to add more into this code to start at row 6? 代码将删除D中的所有空单元格,我想要的是,有没有办法在第6行开始添加更多代码?
I though it would be simple like .Rows(6).Columns(4), but it doesn't seem to work. 我虽然它很简单,如.Rows(6).Columns(4),但它似乎不起作用。 Anyone got an idea how to make this work correctly? 任何人都知道如何使这项工作正常?
尝试这个:
wsIMP.Range("D6","D" & wsIMP.rows.count).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
dim lastrow as Long
With wsIMP
lastrow = .Range("D" & .rows.count).end(xlup).Row
.Range("D6:D" & lastrow).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End With
If you wish to write in one line, as in your comment, do this. 如果您希望在评论中写一行,请执行此操作。
wsIMP.Range("D6:D" & wsIMP.Range("D" & wsIMP.Rows.Count).End(xlUp).Row).SpecialCells ...
But if you ask me, that is much harder to read. 但如果你问我,那就更难读了。
Hm, I haven't worked with coding in excel too much, but I've done quite a bit in Access, and I feel like I remember using either .Colums(6)(4) or .columns(6,4) to do this, maybe give each of those a quick shot. 嗯,我没有过多地使用excel中的编码,但我在Access中做了很多,我觉得我记得使用.Colums(6)(4)或.columns(6,4)来这样做,也许给每个人快速拍摄。 If neither of those work, I'm afraid I can't help. 如果这些都不起作用,我恐怕无法帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.