ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is there a conditional formula to hide and unhide columns? (https://www.excelbanter.com/excel-programming/329963-there-conditional-formula-hide-unhide-columns.html)

Frederic

Is there a conditional formula to hide and unhide columns?
 
Imagine you have a column A, where codes for certain categories are listed. I
would like Columns B and C, which are hidden, to be unhidden, when a certain
code is being entered in column A.

David

Is there a conditional formula to hide and unhide columns?
 
Hi,
Hope this will help.
Private Sub Worksheet_Change(ByVal Target As Range)
Col = ActiveCell.Column
Stop
If Col = 1 And ActiveCell.Value = "Certain Value" Then
ActiveCell.Columns("B:C").EntireColumn.Select
Selection.EntireColumn.Hidden = False
ActiveCell.Select
Else
End If
End Sub

"Frederic" wrote:

Imagine you have a column A, where codes for certain categories are listed. I
would like Columns B and C, which are hidden, to be unhidden, when a certain
code is being entered in column A.


Bob Phillips[_7_]

Is there a conditional formula to hide and unhide columns?
 
A bit simpler, no selects

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.column = 1 And Target.Value = "Certain Value" Then
Columns("B:C")..Hidden = False
End If
End Sub

Also, this code should go into the appropriate sheet code module, not a
standard code module.


--
HTH

Bob Phillips

"David" wrote in message
...
Hi,
Hope this will help.
Private Sub Worksheet_Change(ByVal Target As Range)
Col = ActiveCell.Column
Stop
If Col = 1 And ActiveCell.Value = "Certain Value" Then
ActiveCell.Columns("B:C").EntireColumn.Select
Selection.EntireColumn.Hidden = False
ActiveCell.Select
Else
End If
End Sub

"Frederic" wrote:

Imagine you have a column A, where codes for certain categories are

listed. I
would like Columns B and C, which are hidden, to be unhidden, when a

certain
code is being entered in column A.





All times are GMT +1. The time now is 12:25 PM.

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