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. #1

    Exclamation VBA - hiding column based on value of cell

    Hi,
    i'm trying to do something that i believe is really simple, and for some reason i can't get it to work.
    i have a named range in my excel file named ReductionType in Sheet1. I want columns I:J in Sheet2 to be hidden if the text in reductionType is "One Time". otherwise i want columns G:H hidden.

    I have:

    Sub Macro3() 'macro is called from Sheet2
    Columns("G:J").EntireColumn.Hidden = False 'make sure all columns are unhidden
    Dim reduction As String
    reduction = Range("ReductionType")   'have also tried this with .value appended to the end of this line
    IIf reduction = "One Time Premium Reduction", Columns("I:J").enitrecolumn.Hidden = True, Columns("G:H").EntireColumn.Hidden = True
    End Sub
    and i'm getting errors.
    any ideas please? I'm at a loss....

    thanks!
    Last edited by Aussiebear; 06-27-2020 at 07:24 AM. Reason: Added code tags

Posting Permissions

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