Delete method of Range class failed

sage123

New Member
Joined
Dec 2, 2018
Messages
13
Hi all,


I’m trying to delete the hidden rows and columns from thebelow table. I run a macro to autofilter 2 of the columns (8 & 10) but other than that it is unchanged. The original table is extracted from another document. I’vetried using the below VBA code that I found online however I get an error message saying:

Run time error 1004
Delete method ofRange class failed



Sub deletehidden()
For lp = 256 To 1 Step -1
If Columns(lp).EntireColumn.Hidden = True ThenColumns(lp).EntireColumn.Delete Else
Next
For lp = 65536 To 1 Step -1
If Rows(lp).EntireRow.Hidden = True ThenRows(lp).EntireRow.Delete Else
Next
End Sub

Any help would be greatly appreciated! J
 
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
8 and 10 are rows, not columns, and autofilter hides rows, not columns.
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,637
Members
452,663
Latest member
MEMEH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top