Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ram Ram is offline
external usenet poster
 
Posts: 138
Default Macro run from if then function

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
Ram Ram is offline
external usenet poster
 
Posts: 138
Default Macro run from if then function

I wasn't using uppercase B in the Target. Address. Now it's working fine.


"ram" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Macro run from if then function

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

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
Should I use a macro for this function? dwny Excel Discussion (Misc queries) 3 March 18th 08 10:25 PM
Sub Macro vrs Function Macro Auto Start Pat Excel Discussion (Misc queries) 7 June 6th 07 09:53 PM
Macro Function thuva Excel Worksheet Functions 1 July 26th 06 08:02 AM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Is this a macro or a function? aapp81[_4_] Excel Programming 8 November 20th 03 10:07 PM


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