ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Not Hiding Columns (https://www.excelbanter.com/excel-programming/291096-not-hiding-columns.html)

SS[_3_]

Not Hiding Columns
 
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

Peter Atherton[_16_]

Not Hiding Columns
 
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
-----Original Message-----
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
.



All times are GMT +1. The time now is 08:13 PM.

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