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

I have the following worksheet change event that will be activated when there
is a change to cell E5.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Count 1 Then Exit Sub
If Target.Column = 5 Then
If Target.Row = 1 Then
Call Macro1
End If
End If
End Sub

I have named cell E5 as "Term". What I would like to do is replace the 2 if
statements above with 1 that reads:

if Target.Range = Range("Term") then ...

However, this does not work and I get an error message that reads "Argument
not optional".

Any ideas on how I can get this to work?

Thanks in advance
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default worksheet change event

Target=Range("Term") then

This won't work. Both Target and Range("Term") are ranges, and
their default propreties are Value. This you are comparing the
value of Target and the value of Range("Term"). The code behaves
as if it were written as

Target.Value=Range("Term").Value then

It does not test whether Target is the same range as "Term".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Ardus Petus" wrote in message
...
Hi Fullers,

Target=Range("Term") then

Target is a Range object.

HTH
--
AP

"fullers" a écrit dans le
message de news:
...
I have the following worksheet change event that will be
activated when there
is a change to cell E5.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Count 1 Then Exit Sub
If Target.Column = 5 Then
If Target.Row = 1 Then
Call Macro1
End If
End If
End Sub

I have named cell E5 as "Term". What I would like to do is
replace the 2 if
statements above with 1 that reads:

if Target.Range = Range("Term") then ...

However, this does not work and I get an error message that
reads "Argument
not optional".

Any ideas on how I can get this to work?

Thanks in advance





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default worksheet change event

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Count 1 Then Exit Sub
If Not Intersect(Target,Range("Term")) Is Nothing Then
Call Macro1
End If
End Sub


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"fullers" wrote in message
...
I have the following worksheet change event that will be activated when

there
is a change to cell E5.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Count 1 Then Exit Sub
If Target.Column = 5 Then
If Target.Row = 1 Then
Call Macro1
End If
End If
End Sub

I have named cell E5 as "Term". What I would like to do is replace the 2

if
statements above with 1 that reads:

if Target.Range = Range("Term") then ...

However, this does not work and I get an error message that reads

"Argument
not optional".

Any ideas on how I can get this to work?

Thanks in advance



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
Cell value change to trigger macro (worksheet change event?) Neil Goldwasser Excel Programming 4 January 10th 06 01:55 PM
Change Cell from Validated List Not Firing Worksheet Change Event [email protected] Excel Programming 3 October 4th 04 03:00 AM
Worksheet Change Event nrage21[_57_] Excel Programming 4 August 3rd 04 12:32 AM
Worksheet Change Event Help Please J P Singh Excel Programming 1 July 16th 03 09:37 AM


All times are GMT +1. The time now is 10:19 PM.

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

About Us

"It's about Microsoft Excel"