Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Worksheet_Change

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zimfrancis@hotmail.com - 13 Sep 2007 17:32 GMT
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
FSt1 - 13 Sep 2007 17:58 GMT
hi.
what is the ambiguous message?

regards
FSt1

> Hi Guys,
>
[quoted text clipped - 17 lines]
>
> Any ideas
p45cal - 13 Sep 2007 18:06 GMT
it'll be:
Compile error. Ambiguous name detected:Worksheet_Change
Signature

p45cal

> hi.
> what is the ambiguous message?
[quoted text clipped - 23 lines]
> >
> > Any ideas
p45cal - 13 Sep 2007 18:02 GMT
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.
Signature

p45cal

> Hi Guys,
>
[quoted text clipped - 17 lines]
>
> Any ideas
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.