VBA Worksheet Change If Cell In Range Populates Then Fire Code

Lewzerrrr

Active Member
Joined
Jan 18, 2017
Messages
256
Hi,

I need to fire a code when a cell in a range of J3:J1000 <> "" then fire code.

What I've tried to do is this bit of code however msgbox never shows even when I populate a cell in J.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Range("J3:J1000")) Is Nothing Then Exit Sub


If Range(Target.Address).Value <> "" Then MsgBox "Correct"


End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Sound like events might have been disabled. Try running this
Code:
Sub Eve()
Application.EnableEvents = True
End Sub
& then see if your event works.
Also you could write this line
Code:
If Range(Target.Address).Value <> "" Then MsgBox "Correct"
Like
Code:
If Target.Value <> "" Then MsgBox "Correct"
 
Upvote 0
Sound like events might have been disabled. Try running this
Code:
Sub Eve()
Application.EnableEvents = True
End Sub
& then see if your event works.
Also you could write this line
Code:
If Range(Target.Address).Value <> "" Then MsgBox "Correct"
Like
Code:
If Target.Value <> "" Then MsgBox "Correct"

Thanks, very bizarre not working. I have this code also in this sheet which works fine. Maybe it's conflicting? Maybe I can add onto this instead?

This code just pops in a tick on double click in that I3:L500 region. If possible to then if cell in J column has a tick then run a seperate code?

What I'm trying to achieve overall is for my users to double click the cells in that range but if they pop a tick in J3:J1000 then send an email. So I assume I need a worksheet change targeting just J?

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)    If Not Intersect(Target, Range("I3:L500")) Is Nothing Then
        Application.EnableEvents = False
        If ActiveCell.Value = ChrW(&H2713) Then
            ActiveCell.ClearContents
        Else
            ActiveCell.Value = ChrW(&H2713)
        End If
        Cancel = True
    End If
    Application.EnableEvents = True
End Sub
 
Last edited:
Upvote 0
If I understand you correctly, maybe something like this
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("I3:L500")) Is Nothing Then
        Application.EnableEvents = False
        If ActiveCell.Value = ChrW(&H2713) Then
            ActiveCell.ClearContents
        Else
            ActiveCell.Value = ChrW(&H2713)
        End If
        If Target.Column = 10 And Target.Value = ChrW(&H2713) Then
            Call SomeMacro(Target)
        End If

        Cancel = True
    End If
    Application.EnableEvents = True
End Sub
' In a normal module
Sub SomeMacro(Rng As Range)
MsgBox Rng.Address
End Sub
Where SomeMacro goes in a standard module
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,304
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