Not Hiding Columns

  • Thread starter Thread starter SS
  • Start date Start date
S

SS

When my code runs, if columns F - P are not already
hidden, the following code is not hiding them


ActiveSheet.Columns("F:AM").Select
Selection.EntireColumn.Hidden = True

I ultimately want all columns from F to AM to be hidden in
certain circumstances, but if a portion of the columns
have been previously unhidden it will not hide them again.

Thoughts?

Thanks

SS
 
Try unhiding them first before you set the conditions.

range("F1:AM1).entireColumns.Hidden = FAlse
For i = 3 to 20
if cells(i,1) = 0 Then
cells(1,i).entirecolumn.hidden= True
end if
Next i

Each column will have to be hidden separately if say
column A = 0

Regards
Peter
 
Back
Top