Trigger macro if range contains

Chewyhairball

Active Member
Joined
Nov 30, 2017
Messages
312
Office Version
  1. 365
Platform
  1. Windows
[FONT=&quot]Private Sub Worksheet_Change(ByVal Target As Range)[/FONT]
[FONT=&quot]If Not Intersect(Target, Range("A12")) Is Nothing Then[/FONT]
[FONT=&quot] If Range("A12").Value = "Bin1" Then Call ‘my macro’[/FONT]
[FONT=&quot]End If[/FONT]
[FONT=&quot]End Sub[/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot]Hi[/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot]I have the above code that triggers ‘my macro’ when the text ‘Bin1’ is entered into cell A12, and it works fine.[/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot]Is there a way for it to trigger ‘my macro’ if ‘Bin1’ is entered into any cell within the range A12:A1000 and not just A12[/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot]I don’t need it to trigger if it is entered multiple times, but if i remove all references to ‘bin1’ i would like it to trigger if it entered again.[/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot]thanks[/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot]for any help[/FONT]
[FONT=&quot]
[/FONT]

[FONT=&quot]Rory[/FONT]
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try this

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("A12:A1000")) Is Nothing Then
    If Target.Count > 1 Then Exit Sub
    If Target.Value = "" Then Exit Sub
    If LCase(Target.Value) = LCase("Bin1") Then Call my_macro
  End If
End Sub
 
Upvote 0
Try this

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("A12:A1000")) Is Nothing Then
    If Target.Count > 1 Then Exit Sub
    If Target.Value = "" Then Exit Sub
    If LCase(Target.Value) = LCase("Bin1") Then Call my_macro
  End If
End Sub

awesome! works perfect. I love excel

Thank you DanteAmor
:)
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,949
Members
448,534
Latest member
benefuexx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top