Cell Change Run Code

helpexcel

Well-known Member
Joined
Oct 21, 2009
Messages
656
I', assuming this code will run if any cell on Sheet1 is changed? How do i change it to only run if a cell in J1:J15 is changed?


Code:
If Target.Cells.Count <> 1 Then Exit Sub    
If Not Intersect(Target, Range("J1:J15")) Is Nothing Then
       Select Case Target.Value
        Case "Apple"
            Call Kawhi
        Case "Three"
            Call Curry
        End Select
End If
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Difficult to answer your question exactly, because you have not included the entire code. We have no way of knowing if that a change event, selection change event, or something completely different.
The opening line can be one of the most important parts of the code.
Can you please post the complete code.
 
Upvote 0
I left this piece out, but that's my code.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 
Upvote 0
In that case the code will only run when you change a value in J1:J15.
Whilst it will trigger whenever you change any cell, nothing will happen.
 
Upvote 0
Yes, just add an ElseIf before the End If & specify the range
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

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