简体   繁体   English

excel中最后使用的单元格太大,试图删除多余的列和行时excel崩溃

[英]Last used cell in excel is so large excel crashes when trying to delete excess columns and rows

I have a worksheet where the last used cell is said to be cells(1048381,BH). 我有一个工作表,其中最后一次使用的单元格称为单元格(1048381,BH)。 I know I'm supposed to delete all rows (and columns, but less relevant in this particular case as all columns through BH are actually be used) until the final row, but the final row is such a large number that excel (64-bit) crashes when I go to fix the problem. 我知道我应该删除所有行(和列,但在这种特殊情况下不那么相关,因为实际上使用了BH的所有列),直到最后一行为止,但是最后一行的数量如此之多,以至于表现出色(64-位)崩溃,当我去解决这个问题。 Any recommendations? 有什么建议吗?

Thanks! 谢谢!

You don't actually have to delete the rows between the last valid row of data and a rogue last cell. 实际上,您不必删除最后一个有效数据行与一个恶意最后一个单元格之间的行。 Using Home, Editing, Clear, Clear All is sufficient and is much less calculation intensive. 使用“主页”,“编辑”,“清除”,“全部清除”就足够了,并且计算强度更低。

Here is some code that performs the same action on a rogue populated cell. 这是一些代码,可以对流氓填充的单元格执行相同的操作。

Option Explicit

Sub resetRogueRow()

    Dim lr As Long, nr As Long

    With Worksheets("sheet2")

        lr = .Cells.Find(What:="*", _
                         After:=.Cells(1), _
                         LookAt:=xlWhole, _
                         LookIn:=xlFormulas, _
                         SearchOrder:=xlByRows, _
                         SearchDirection:=xlPrevious, _
                         MatchCase:=False).Row
        nr = .Cells.Find(What:="*", _
                         After:=.Cells(lr, 1), _
                         LookAt:=xlWhole, _
                         LookIn:=xlFormulas, _
                         SearchOrder:=xlByRows, _
                         SearchDirection:=xlPrevious, _
                         MatchCase:=False).Row

        .Cells(nr + 1, "A").Resize(lr - nr, 1).EntireColumn.Clear

    End With
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM