Results 1 to 4 of 4

Hide column depending giving value in another worksheet

Threaded View

  1. #1
    Forum Contributor
    Join Date
    09-04-2007
    Posts
    127

    Hide column depending giving value in another worksheet

    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.
    Attached Files Attached Files
    Last edited by VBA Noob; 06-20-2008 at 03:24 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1