Linking my VB macro to cells?

jwp

New Member
Joined
Aug 31, 2011
Messages
33
I may be doing this wrong but if you could help that would be great.

Now I have my VB macro written and I want to link it to several cells. For example A1, A2, and A3.

Is there a way for my macro to run against these cells when data is entered into them?

Hope that is clear. Thank you!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
You can use the Worksheet_Change event procedure (in the module for the worksheet):

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Application.Intersect(Target, Range("A1:A3")) Is Nothing Then Exit Sub
'   Your code here
End Sub
 
Upvote 0
Right Click on sheets Name --View Code , then test this code
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Range("A1:A3"), Target) Is Nothing Then
'your code here
End If
End Sub
 
Upvote 0
Man this board rocks, you ask a question and get an answer within the hour.

Will test it out and let you know.

Thank you
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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