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 / May 2006

Tip: Looking for answers? Try searching our database.

Macro run from if then function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ram - 24 May 2006 14:41 GMT
The code below only runs if the Target.Address = "$A$1" . If i change the
Target.Address to ="$B$1" and make a change to cell B1 the macro won't run.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.Run "Test_Output_file!Macro1"
End If
End Sub

Thanks in advance for any help
ram - 24 May 2006 14:50 GMT
I wasn't using uppercase B in the Target. Address. Now it's working fine.

> The code below only runs if the Target.Address = "$A$1" . If i change the
> Target.Address to ="$B$1" and make a change to cell B1 the macro won't run.
[quoted text clipped - 6 lines]
>
> Thanks in advance for any help
Ivan Raiminius - 24 May 2006 14:53 GMT
Hi,

you are comparing two strings, so you have to be sure that they will be
the same (if target.address is "$B$1" and in your condition you have
Target.Address = "$b$1", then these two strings don't match).

There are many ways how to do it:

If Target.Address = range("b1").address Then

or

if not intersect(target,range("b1") is nothing then

for example.
Regards,
Ivan
 
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.