Posted by: tfabris
Yet Again More Excel Help - Button to hide and show colums - 14/04/2010 19:29
I added a button to my worksheet. The button is supposed to hide and unhide columns which contain a paragraph of descriptive text.
When the columns are shown, I need to have the text-wrap turned on so you can see everything. When the columns are hidden, they need the wrap off to keep the data in the document readable.
Within the "IF" statement, sometimes only the first of the paired statements gets executed. Sometimes they both get executed. I can see this happening in the step-by-step debugger.
I don't think it's because of the malleable state of the ".Hidden" property, because I tried to copy that into to a variable at the top of the function and then execute a different IF statement based on the variable, and I got the same results.
What's up here?
When the columns are shown, I need to have the text-wrap turned on so you can see everything. When the columns are hidden, they need the wrap off to keep the data in the document readable.
Code:
Sub Button1_Click() With Worksheets("My Worksheet Name").Columns("D:E") If .Hidden Then .Hidden = False .WrapText = True Else .WrapText = False .Hidden = True End If End With End Sub
Within the "IF" statement, sometimes only the first of the paired statements gets executed. Sometimes they both get executed. I can see this happening in the step-by-step debugger.
I don't think it's because of the malleable state of the ".Hidden" property, because I tried to copy that into to a variable at the top of the function and then execute a different IF statement based on the variable, and I got the same results.
What's up here?