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

Hi Guys,

I have tried to use the code:

Private Sub Worksheet_Change(ByVal Target As Range)

Rows("6:18").EntireRow.Hidden = False
Rows("20:37").EntireRow.Hidden = False

If Range("c5") = "1" Then
Rows("13:18").EntireRow.Hidden = True
ElseIf Range("c5") = "2" Then
Rows("20:37").EntireRow.Hidden = True
End If


End Sub

The code works ok with one change event. I would like to use it 3-4
times in a worksheet, but get an ambiguous message.

Any ideas

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Worksheet_Change

hi.
what is the ambiguous message?

regards
FSt1

" wrote:

Hi Guys,

I have tried to use the code:

Private Sub Worksheet_Change(ByVal Target As Range)

Rows("6:18").EntireRow.Hidden = False
Rows("20:37").EntireRow.Hidden = False

If Range("c5") = "1" Then
Rows("13:18").EntireRow.Hidden = True
ElseIf Range("c5") = "2" Then
Rows("20:37").EntireRow.Hidden = True
End If


End Sub

The code works ok with one change event. I would like to use it 3-4
times in a worksheet, but get an ambiguous message.

Any ideas


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Worksheet_Change

I think you can only have 1 Sub Worksheet_Change per sheet, however, you can
use Target (the cells which triggered the change) to decide on a course of
action within that sub.

eg (pseudocode)
if target.column = 3 then do something
if target.column = 2 then do something else


you can check if Target is within a specified range (real code):

If Not Intersect(Target, Range("A3:C6")) Is Nothing Then
MsgBox "It's a hit!"
Else
'do something else
End If

or you can use the Select Case facility.
--
p45cal


" wrote:

Hi Guys,

I have tried to use the code:

Private Sub Worksheet_Change(ByVal Target As Range)

Rows("6:18").EntireRow.Hidden = False
Rows("20:37").EntireRow.Hidden = False

If Range("c5") = "1" Then
Rows("13:18").EntireRow.Hidden = True
ElseIf Range("c5") = "2" Then
Rows("20:37").EntireRow.Hidden = True
End If


End Sub

The code works ok with one change event. I would like to use it 3-4
times in a worksheet, but get an ambiguous message.

Any ideas


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Worksheet_Change

it'll be:
Compile error. Ambiguous name detected:Worksheet_Change
--
p45cal


"FSt1" wrote:

hi.
what is the ambiguous message?

regards
FSt1

" wrote:

Hi Guys,

I have tried to use the code:

Private Sub Worksheet_Change(ByVal Target As Range)

Rows("6:18").EntireRow.Hidden = False
Rows("20:37").EntireRow.Hidden = False

If Range("c5") = "1" Then
Rows("13:18").EntireRow.Hidden = True
ElseIf Range("c5") = "2" Then
Rows("20:37").EntireRow.Hidden = True
End If


End Sub

The code works ok with one change event. I would like to use it 3-4
times in a worksheet, but get an ambiguous message.

Any ideas


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
worksheet_change help please AmyTaylor[_47_] Excel Programming 2 April 6th 06 07:44 PM
Worksheet_Change [email protected] Excel Programming 2 November 22nd 04 12:17 AM
worksheet_change vs. calculate, and worksheet_change not running Tom Ogilvy Excel Programming 1 July 14th 03 02:51 AM
worksheet_change vs. calculate, and worksheet_change not running Ross[_5_] Excel Programming 0 July 13th 03 04:27 PM


All times are GMT +1. The time now is 09:53 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"