hide-unhide

H

hoysala

i have written the following code to hide a column

can anybody help me altering the program to swap between hide and
unhide using the same CommandButton ?



Private Sub CommandButton5_Click()

If ActiveSheet.Name = SHEETNAME Then

If Worksheets(SHEETNAME).Columns("c:t").Hidden = False Then
Worksheets(SHEETNAME).Columns("c:t").Hidden = True
End If

End If

End Sub
 
J

Jim Rech

Private Sub CommandButton5_Click()
If ActiveSheet.Name = SHEETNAME Then
Columns("c:t").Hidden = Not .Columns("c:t").Hidden
End If
End If


--
Jim
|i have written the following code to hide a column
|
| can anybody help me altering the program to swap between hide and
| unhide using the same CommandButton ?
|
|
|
| Private Sub CommandButton5_Click()
|
| If ActiveSheet.Name = SHEETNAME Then
|
| If Worksheets(SHEETNAME).Columns("c:t").Hidden = False Then
| Worksheets(SHEETNAME).Columns("c:t").Hidden = True
| End If
|
| End If
|
| End Sub
 
O

Office_Novice

Try a Toggle Button and this.

Option Explicit

Private Sub ToggleButton1_Click()
If ActiveSheet.Name = ("Sheet1") Then

If Worksheets("Sheet1").Columns("C:T").Hidden = False Then
Worksheets("Sheet1").Columns("C:T").Hidden = True

ElseIf Worksheets("Sheet1").Columns("C:T").Hidden = True Then
Worksheets("Sheet1").Columns("C:T").Hidden = False
End If

End If
End Sub

HTH
 
J

JLGWhiz

Private Sub CommandButton5_Click()

If ActiveSheet.Name = SHEETNAME Then

If Worksheets(SHEETNAME).Columns("c:t").Hidden = False Then
Worksheets(SHEETNAME).Columns("c:t").Hidden = True
Else
Worksheets(SHEETNAME).Columns("c:t").Hidden = False
End If

End If

End Sub
 
E

eliano

Hi Hoy. :)
For a very "personal" solution (no Button, etc), try:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
Cancel = True

With ActiveSheet
If .Columns("c:t").Hidden = False Then
.Columns("c:t").Hidden = True
Else
.Columns("c:t").Hidden = False
End If
End With

End Sub

Saluti
Eliano
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top