ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Un hide non empty columns (https://www.excelbanter.com/excel-programming/355225-un-hide-non-empty-columns.html)

[email protected]

Un hide non empty columns
 
Is there a macro to un-hide already hidden column which are not blank?

Thanks


Joseph_L

Un hide non empty columns
 

Try this:

Sub UnhideCol()
Dim I As Integer, StartAdr As Variant, EndAdr As Variant
StartAdr = Range("A1").Address
EndAdr = Range("A65536").Address
For I = 0 To 255
StartAdr = Range("A1").Offset(0, I).Address
EndAdr = Range("A65536").Offset(0, I).Address
If Application.WorksheetFunction.CountBlank(Range(Sta rtAdr & ":" &
EndAdr)) < 65536 Then
Range(StartAdr & ":" & EndAdr).EntireColumn.AutoFit
End If
Next I
Range("A1").Select
End Sub

Jozef


--
Joseph_L
------------------------------------------------------------------------
Joseph_L's Profile: http://www.excelforum.com/member.php...fo&userid=7202
View this thread: http://www.excelforum.com/showthread...hreadid=519428


Joseph_L[_2_]

Un hide non empty columns
 

Wrote:
Is there a macro to un-hide already hidden column which are not blank?

Thanks

Try this:

Sub UnhideCol()
Dim I As Integer, StartAdr As Variant, EndAdr As Variant
StartAdr = Range("A1").Address
EndAdr = Range("A65536").Address
For I = 0 To 255
StartAdr = Range("A1").Offset(0, I).Address
EndAdr = Range("A65536").Offset(0, I).Address
If Application.WorksheetFunction.CountBlank(Range(Sta rtAdr & ":" &
EndAdr)) < 65536 Then
Range(StartAdr & ":" & EndAdr).EntireColumn.AutoFit
End If
Next I
Range("A1").Select
End Sub


--
Joseph_L


------------------------------------------------------------------------
Joseph_L's Profile:
http://www.excelforum.com/member.php...fo&userid=7202
View this thread: http://www.excelforum.com/showthread...hreadid=519429



All times are GMT +1. The time now is 09:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com