Cannot get a Macro to run automatically

[Closed]
Report
-
Posts
1864
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
-
Hello,

I am really struggling to get a macro to run automatically. I have created a sheet that logs entry/exit from my offices. I have created a macro that searches all the entered text and when it finds two entries the same it deletes both. (If the name appears the staff member is in, if it doesn't then they are not here!)

I now need this to run everytime a cell is filled in. I have tried using the Worksheet change event however this seems to result in nothing happening. I am completely at a loss as to what to do as I have been working with VB for a short while but have been self educated (largely thanks to forums like this!) so have large gaps in my understanding of how it all works. The code I have so far is:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "A:A" Then

Call Remove_Duplicates

End Sub

Remove_Duplicates is the name of my Macro.
This is entered onto the worksheet page in VB but does nothing! I have tried using a specific cell as the target but still to no avail. Can anyone please help as I am several hours into this and very confused!

Many Thanks,

Leigh

1 reply

Posts
1864
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
802
instead of this line
If Target.Address = "A:A" Then
use
if target.column=1 then

now see whether it works.

even though if you park the macro "remove_dupliates" in "worksheet page" it works it is better to park it in the standard module.