Consulting

Results 1 to 3 of 3

Thread: VBA - hiding column based on value of cell

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Assuming the named range refers to Range A1 in Sheet1, this code need to sit in the Sheet1's code Module, easiest way to get there is to right click in the name tab in the bottom and click view code.

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    
        Dim MyRange As Range
        Dim TargetRange As Range
    
    
        Set MyRange = Me.Range("ReductionType")
        Set TargetRange = Sheet2.Range("G:H")
        
        If MyRange.Value = "One Time" Then
            TargetRange.EntireColumn.Hidden = True
        Else
            TargetRange.EntireColumn.Hidden = False
        End If
    
    
    End Sub
    Last edited by BIFanatic; 06-23-2020 at 09:30 AM.

Posting Permissions

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