Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking for a way that will hide row "I" if range: QTYCALCON is shown.

So far I came up with this.

Sub Hide_Show()
 With Range("QTYCALCON").EntireColumn
  .Hidden = Not .Hidden
 End With
End Sub
share|improve this question
1  
Your question is a bit confusing and lacks detail. You state you want to hide a row, but your title and code refer to column. Please edit your question to clarify. Is "QTYCALCON" a column heading, named range or a table? –  CharlieRB Mar 28 '13 at 16:49
add comment

2 Answers

I assumed "I" was a column and you want the code to work both ways depending on which column is hidden. So, here is the code I would use.

Sub Hide_Show()
    If Range("QTYCALCON").EntireColumn.Hidden = False Then
        Columns("I").Hidden = True
    ElseIf Range("QTYCALCON").EntireColumn.Hidden = True Then
        Columns("I").Hidden = False
    End If
End Sub

Each time you run it, it will check to see if "QTYCALCON" is hidden. If not, it will hide "I". If "QTYCALCON" is hidden, this will unhide "I".

share|improve this answer
add comment

That should be rather posted in Stack Overflow. However, here it goes for hiding column I:

Sub Hide_Show()
With Range("QTYCALCON").EntireColumn
    If Not .Hidden Then
        Range("I:I").EntireColumn.Hidden= True
    End If
End With
End Sub
share|improve this answer
    
This hides both columns if .Hidden is TRUE. I believe they want "I" hidden if "QTYCALCON" is not. –  CharlieRB Mar 28 '13 at 17:14
    
Oh, yeah, you right... so, small correction. Thanks! –  Kaz Jaw Mar 28 '13 at 17:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.