excelvbashow

How to link two cell so that if you insert text in a cell the other become unhidden?


I have an excel document with two sheets. If you put text in the C column of the first sheet, it should unhide the corresponding block of cells (for exemple C6 in the first sheet is equivalent to row 5 to 11 of the second sheet) in the second sheet. I'm new to coding and even more to VBA, so I don't know how to do it.[enter link description here]


Solution

  • In VBA, you have to use the Worksheet_Change event.

    1. ALT-F11 to open VBA

    2. Find your Workbook

    3. Find your Worksheet and double on click it.

    4. Add the following code to start your adventure.

      Private Sub Worksheet_Change(ByVal Target As Range)
      
      If Target.Address = "$B$2" Then
      
          ' Do the work. Good luck. We're all counting you.
      
      End If
      
      End Sub