View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Jodie Jodie is offline
external usenet poster
 
Posts: 72
Default Hide column if it contains text

Thank you Jacob. This works, but is there a way to ignore rows 1 & 2 when
determining if there is text in the column?
--
Thank you, Jodie


"Jacob Skaria" wrote:

Hi Jodie

Try the below

Sub ColHide()
For Each ws in Worksheets
With ws
For Each Col In ws.UsedRange.Columns
If WorksheetFunction.CountIf(ws.Columns(Col.Column), "?*") < 0 Then
Col.EntireColumn.Hidden = True
End If
Next
End With
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jodie" wrote:

What if I want to do this for all worksheets in a workbook?
--
Thank you, Jodie


"Jacob Skaria" wrote:

Hi Jodie

If you dont have formulas in the range...the below will do..Will hide
columns which contain text..

Sub ColHide()
For Each Col In ActiveSheet.UsedRange.Columns
If WorksheetFunction.CountIf(Columns(Col.Column), "?*") < 0 Then
Col.EntireColumn.Hidden = True
End If
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jodie" wrote:

I want to hide all columns containing text and leave the numeric columns
unhidden. Is there a macro that can be written for that?
--
Thank you, Jodie