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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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,223,905
Messages
6,175,297
Members
452,633
Latest member
DougMo

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