I have attached one workbook. It contains two sheets. "input" & "output" sheets. Now I need to hide/unhide column by giving the plant nos 1 or 2 or 3 in the cell E5 of "input sheet". I have used the below code.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False) = "E5" Then
If Target.Value = 1 Then
Sheets("output").Range("f:g").Columns.Hidden = False
Sheets("output").Range("i:j,l:m").Columns.Hidden = True
ElseIf Target.Value = 2 Then
Sheets("output").Range("i:j").Columns.Hidden = False
Sheets("output").Range("f:g,l:m").Columns.Hidden = True
ElseIf Target.Value = 3 Then
Sheets("output").Range("l:m").Columns.Hidden = False
Sheets("output").Range("f:g,i:j").Columns.Hidden = True
End If
End If
End Sub
The above code is working but my problem is this code is applied in "input' sheet. There are one more "Sub Worksheet_Change(ByVal Target As Range)" name macro are already available in the "input" sheet (in my ORIGINAL WORKBOOK, the attached is just a sample of that). Can I use code which is to be applied only in "output' sheet NOT "input" sheet.
I will also hide/unhide the column Q, R & S in the "output" sheet in the same manner. Please suggest.
Thanks in advance.
Bookmarks