Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Hide Columns w/Change Event

Tom Ogilvy responded to the first post I sent awhile ago,
but I'm getting an error executing the code he was nice
enough to give me; "Method range of object_worksheet
failed." I've tried several things and keep getting the
error. The code hides 3 columns if "EDLC" is the
selection. Any help is greatly appreciated; the error
occurs on both "If" lines.

Sub Worksheet_Change(ByVal Target As Excel.Range)

If Application.Intersect(Target, Range("Plan Costs!e1")) _
= "Hi-Low" Then
Exit Sub
End If
If Application.Intersect(Target, Range("Plan Costs!e1")) _
= "EDLC" Then
Sheets("Period 1").Columns("M:O") _
.EntireColumn.Hidden = True

End If

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Hide Columns w/Change Event

Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$E$1" Then
If Target.Value _
= "Hi-Low" Then
Exit Sub
End If
If Target.Value _
= "EDLC" Then
Sheets("Period 1").Columns("M:O") _
.EntireColumn.Hidden = True

End If
End If
End Sub

Worked fine for me. This assumes the code is in the sheet module for sheet
Plan Costs

--
Regards,
Tom Ogilvy

"Eva Shanley" wrote in message
...
Tom Ogilvy responded to the first post I sent awhile ago,
but I'm getting an error executing the code he was nice
enough to give me; "Method range of object_worksheet
failed." I've tried several things and keep getting the
error. The code hides 3 columns if "EDLC" is the
selection. Any help is greatly appreciated; the error
occurs on both "If" lines.

Sub Worksheet_Change(ByVal Target As Excel.Range)

If Application.Intersect(Target, Range("Plan Costs!e1")) _
= "Hi-Low" Then
Exit Sub
End If
If Application.Intersect(Target, Range("Plan Costs!e1")) _
= "EDLC" Then
Sheets("Period 1").Columns("M:O") _
.EntireColumn.Hidden = True

End If

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Hide Columns w/Change Event

Thanks Tom, now the code works fine. Apparently the
original If Application.Intersect(Target, Range("Plan
Costs!e1")) was causing a problem that I wasn't good
enough to figure out. Thanks again for your help.

-----Original Message-----
Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$E$1" Then
If Target.Value _
= "Hi-Low" Then
Exit Sub
End If
If Target.Value _
= "EDLC" Then
Sheets("Period 1").Columns("M:O") _
.EntireColumn.Hidden = True

End If
End If
End Sub

Worked fine for me. This assumes the code is in the

sheet module for sheet
Plan Costs

--
Regards,
Tom Ogilvy

"Eva Shanley" wrote

in message
...
Tom Ogilvy responded to the first post I sent awhile

ago,
but I'm getting an error executing the code he was nice
enough to give me; "Method range of object_worksheet
failed." I've tried several things and keep getting the
error. The code hides 3 columns if "EDLC" is the
selection. Any help is greatly appreciated; the error
occurs on both "If" lines.

Sub Worksheet_Change(ByVal Target As Excel.Range)

If Application.Intersect(Target, Range("Plan Costs!

e1")) _
= "Hi-Low" Then
Exit Sub
End If
If Application.Intersect(Target, Range("Plan Costs!

e1")) _
= "EDLC" Then
Sheets("Period 1").Columns("M:O") _
.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
Want to Hide columns in spreadsheet but NOT hide data in chart. KrispyData Charts and Charting in Excel 1 March 20th 09 04:45 PM
Hide Columns w/Change Event Eva Shanley[_2_] Excel Programming 2 August 26th 04 03:24 PM
Excel VBA-hide row worksheet event kabrahani Excel Programming 2 April 3rd 04 06:18 PM
change event/after update event?? scrabtree23[_2_] Excel Programming 1 October 20th 03 07:09 PM
Pivot Table NewSheet Event Hide Columns Tysone Excel Programming 2 October 15th 03 01:51 AM


All times are GMT +1. The time now is 12:57 PM.

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"