Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    May 2005
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hiding columns if condition is not met (Excel)

    I am having trouble initiating a macro which looks in a worksheet"INPUT" in cell G129 to see if the value is True. If it is then the columns S,T,U,V are to show, if False columns STUV are hidden

    I have included my workbook. Maybe someone could look at my coding for me.

    Thanks

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding columns if condition is not met (Excel)

    The workbook you uploaded contains no code.

    If cell G129 on worksheet INPUT contains TRUE OR FALSE, you want columns S:V on which sheet to be visible or hidden?

    Are you looking for a text value TRUE or FALSE in that cell, or the logical value TRUE or FALSE?

    What do you want to happen to columns S:V if the cell contains something other than TRUE/FALSE? For example what should happen to S:V if cell G129 is empty?
    Legare Coleman

  3. #3
    2 Star Lounger
    Join Date
    May 2005
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding columns if condition is not met (Excel)

    Iwonder why the code never got loaded?
    here it is

    Sub NitrogenColumnHide()
    Colshow = Worksheet("INPUT").Range(G129).Value
    If Colshow = "True" Then
    Application.ActiveWorksheets("Prop Schedule").Columns(S, T, U, V).Show
    Else
    Application.ActiveWorksheets("Prop Schedule").Columns(S, T, U, V).Hide
    End If
    End Sub

    I am trying to show or hide cells s t u v on the Proppent Schedule sheet. based on if Cell G129 on the Input sheet is True or False. True =shoe, False = Hide.
    Another thing is I am wondering howe I can fire this code. how can I make it event driven with out a button. Is it possible to run he macro everytime cell G129 on the input sheet changes?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hiding columns if condition is not met (Excel)

    > Iwonder why the code never got loaded?

    Because it wasn't present in the version you attached. Maybe you hadn't saved the workbook after creating the code. If you attach a file, it is always the saved version on disk, not the version you have open on your screen.

  5. #5
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding columns if condition is not met (Excel)

    I took a guess at the answer to my questions that you did not answer. The attached workbook contains code in the Worksheet Change Event routine for the "INPUT" worksheet that fires when that sheet is changed. The code looks for a logical TRUE/FALSE value in cell G129 and shows/hides the columns appropriately. It does nothing if the cell contains anything other than TRUE/FALSE.
    Legare Coleman

  6. #6
    2 Star Lounger
    Join Date
    May 2005
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding columns if condition is not met (Excel)

    yes sorry about my answer, and thanks for giving me help. I have attached a beeter example. your answer is exactly what I wanted. I forgot to mention that the True false is calculated on a IF statement. this would make it based on a formula. I wasnt sure is a formula returning a True or False was different then just typing true or false in the cell.

    I have attached an example.

  7. #7
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding columns if condition is not met (Excel)

    OK, that does change things. Does this do what you want?
    Legare Coleman

  8. #8
    2 Star Lounger
    Join Date
    May 2005
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding columns if condition is not met (Excel)

    Tes thanks Legare, It does do what I want. when I added it to my worksheet it stopped though. I named the range. I have attached what I did. Maybe you could look and help me in getting it to work,

  9. #9
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding columns if condition is not met (Excel)

    You deleted the fill list for the COMBOBOX. I created one in H117:H119, and recreated the EnergizedList to point to it, and everything seems to work. You will need to recreate the real list.
    Legare Coleman

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hiding columns if condition is not met (Excel)

    Well, for one thing the combo box over B117 has a non-existent named range as list fill range, so it doesn't work. The code still runs OK if the value of co2n2energized changes.

Posting Permissions

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