Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Hide and unhide columns

I have the following statement. Instead of hiding and unhiding the range
"B:J", I want to hide and unhide Columns "B,D,f,H"

Please find below the statement I have used. Any advise would be very much
appreciated.


Private Sub CommandButton1_Click()
Macro2
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
Dim arr As Variant

arr = Array("EO", "EC", "ES", "EV", "EF", "EG")
If Target.Cells.Count 1 Then Exit Sub

If Target.Column = 1 Then
Columns("B:J").EntireColumn.Hidden = _
IsError(Application.Match(Target.Value, arr, 0))
End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Union(Range("A:A"), Range("B:J"))) Is Nothing Then
Columns("B:J").EntireColumn.Hidden = True
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Hide and unhide columns

Columns("B:B,D:D,F:F,H:H").EntireColumn.Hidden.... ...etc

(BTW: The macro recorder could have told you the same)

Wolf

"Frederic" wrote:

I have the following statement. Instead of hiding and unhiding the range
"B:J", I want to hide and unhide Columns "B,D,f,H"

Please find below the statement I have used. Any advise would be very much
appreciated.


Private Sub CommandButton1_Click()
Macro2
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
Dim arr As Variant

arr = Array("EO", "EC", "ES", "EV", "EF", "EG")
If Target.Cells.Count 1 Then Exit Sub

If Target.Column = 1 Then
Columns("B:J").EntireColumn.Hidden = _
IsError(Application.Match(Target.Value, arr, 0))
End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Union(Range("A:A"), Range("B:J"))) Is Nothing Then
Columns("B:J").EntireColumn.Hidden = True
End If
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Hide and unhide columns

Hi Frederick,

Try:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim arr As Variant
Dim rng As Range

Set rng = Range("B1, D1, F1, H1")

arr = Array("EO", "EC", "ES", "EV", "EF", "EG")
If Target.Cells.Count 1 Then Exit Sub

If Target.Column = 1 Then
rng.EntireColumn.Hidden = _
IsError(Application.Match(Target.Value, arr, 0))
End If

End Sub


---
Regards,
Norman



"Frederic" wrote in message
...
I have the following statement. Instead of hiding and unhiding the range
"B:J", I want to hide and unhide Columns "B,D,f,H"

Please find below the statement I have used. Any advise would be very much
appreciated.


Private Sub CommandButton1_Click()
Macro2
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
Dim arr As Variant

arr = Array("EO", "EC", "ES", "EV", "EF", "EG")
If Target.Cells.Count 1 Then Exit Sub

If Target.Column = 1 Then
Columns("B:J").EntireColumn.Hidden = _
IsError(Application.Match(Target.Value, arr, 0))
End If

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Union(Range("A:A"), Range("B:J"))) Is Nothing Then
Columns("B:J").EntireColumn.Hidden = True
End If
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How Unhide & Hide Columns with VBA jean Excel Discussion (Misc queries) 1 June 17th 09 02:03 AM
Automatically hide/unhide columns laststraw Excel Discussion (Misc queries) 11 September 12th 07 12:54 PM
Hide/Unhide columns using button on top over relevant columns [email protected] Excel Discussion (Misc queries) 1 March 7th 07 09:24 PM
Unhide and hide columns [email protected] Excel Worksheet Functions 1 October 23rd 06 07:16 PM
hide / unhide columns appeng Excel Programming 1 March 25th 05 10:16 PM


All times are GMT +1. The time now is 09:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"