Consulting

Results 1 to 2 of 2

Thread: Error when deleting

  1. #1
    VBAX Contributor
    Joined
    Aug 2006
    Posts
    120
    Location

    Error when deleting

    I have a database with plenty of data. Suddenly I needed to delete a specific range but each time i deleted that range an error pops up.
    excel error "-2147417848" Is there an issue with names? comments? anything? I wrote a sub to illustrate. thanks.

  2. #2
    This is strange indeed. I experimented a bit, and found the following:
    • If you try to delete columns B: DZ manually (i.e. from menu), Excel crashes and wants to report error to Microsoft.
    • You can delete the range in parts, (e.g. first columns AA: DZ then columns B:Z) without crash.
    • If you select any column and clear its formatting, then you can delete columns B: DZ without crash. The "unformatted" column can be any one, doesn't have to be within B: DZ
    • If you clear the format of row #4, you can delete columns B: DZ without crash. Other rows are irrelevant.
    • Examining row #4 more closely revealed that this problem is probably rooted in merged cells. I have not found any merged cells in row #4. However, if you select row #4, merge its cells then unmerge them, then you can delete columns B: DZ without crash.
    I suspect something is hiding in the worksheet, an unseen remainder of a formatting operation or another. If you need to somehow get rid of it.

    Alternatively, you can use this workaround:
    [vba]Sub Delete()
    Columns("CZ").Delete
    Columns("B:B").Delete
    End Sub
    [/vba]
    HTH

    Jimmy
    -------------------------------------------------
    The more details you give, the easier it is to understand your question. Don't save the effort, tell us twice rather than not at all. The amount of info you give strongly influences the quality of answer, and also how fast you get it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •