PDA

View Full Version : Error when deleting



makako
05-14-2008, 03:29 PM
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.

JimmyTheHand
05-15-2008, 01:14 AM
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:
Sub Delete()
Columns("C:DZ").Delete
Columns("B:B").Delete
End Sub

HTH

Jimmy