VBA code to run and call macro if any new text is added to a column

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
886
Office Version
  1. 365
Platform
  1. Windows
I am looking for a code that will run if any new text is added to a column.
Basically In column D:D there will be a drop down list of employee names that as soon as a name is selected I will be having excel e-mail that particular employee information.
I just need help with what will trigger that macro.

I only know the code if there is specific text involved but in this case employee names change all the time...

Thank you

Carla
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi Carla,

Try this event macro on the tab you want the email code to run after a change in Col. D:

Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Column = 4 Then
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
            'Hi Carla - your email macro will go here
            .EnableEvents = True
            .ScreenUpdating = True
        End With
    End If

End Sub

Regards,

Robert
 
Upvote 0
Is there a code that could call an already created Macro instead as soon as any new data is entered in column D?

Like:

VBA Code:
If Target.Column = 4 Then Call Notify

Notify is the name of the Macro
 
Upvote 0
How about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Not Intersect(Target, Range("D:D")) Is Nothing Then Call Notify
End Sub
 
Upvote 0
This works but it runs any time any cell is changed in column D. Is there a way to make it ignore if you delete anything in column D/if you make the cell blank?
Say I select an employee name, the macro will run however if I delete that name I do not want it to run...
 
Upvote 0
Try
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Not Intersect(Target, Range("D:D")) Is Nothing Then
        If Target <> "" Then Call Notify
    End If
End Sub
 
Upvote 0
As always Fluff, you are amazing!

Works perfect and love the simplicity of it. Thank you again! :)
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0
Hi Carla,

Try this event macro on the tab you want the email code to run after a change in Col. D:

Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Column = 4 Then
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
            'Hi Carla - your email macro will go here
            .EnableEvents = True
            .ScreenUpdating = True
        End With
    End If

End Sub

Regards,

Robert
Thank you for your code as well Trebor76. I already had the macro and was looking for something slightly different but again Thank you for responding to my question, I appreciate it :)
 
Upvote 0

Forum statistics

Threads
1,214,542
Messages
6,120,116
Members
448,945
Latest member
Vmanchoppy

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