MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Delete Hidden Columns


Posted by Adrae on December 10, 2001 11:40 AM

I am using the following code to delete all hidden columns in a workbook. The macro appears to run ok, but no columns get deleted. What am I doing wrong? Thanks :-) Adrae

Dim Sh As Worksheet, i As Integer
Application.ScreenUpdating = False
For Each Sh In Worksheets
For i = 256 To Step - 1
With Sh.Columns(i).EntireColumn
If .Hidden = True Then .Delete (xlShiftToLeft)
End With
Next
Next


Posted by Dank on December 10, 2001 11:54 AM

Just change

For i = 256 to Step -1

to

For i = 256 to 1 Step -1

Regards,
Daniel.