Delete Hidden Columns


Posted by Adrae on December 14, 2001 7:33 AM

Can anyone tell me why the follwoing is not working:

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

Posted by Dan on December 14, 2001 7:46 AM

What isn't working?

I pasted your code in to a module and it seemed to work fine for me (XL97). Are you getting an error message? If so what is it?

Posted by Adrae on December 14, 2001 8:13 AM

Re: What isn't working?

No error message - it seems to skip over the first sheet. Any ideas? Thanks :-)

Posted by Dan on December 14, 2001 8:53 PM

Still seems to work for me

I made a workbook with hidden columns on different sheets and it deleted the hidden columns on all sheets, including the first one. Sorry, but I can't seem to duplicate the problem. Feel free to send the sheet to me and I can look at yours, if you want.



Posted by Dan on December 14, 2001 8:53 PM

Still seems to work for me

I made a workbook with hidden columns on different sheets and it deleted the hidden columns on all sheets, including the first one. Sorry, but I can't seem to duplicate the problem. Feel free to send the sheet to me and I can look at yours, if you want.