Yes, it should run automatically, make sure that application's events are
enabled.
In the immediate pane type the following, then press Enter:
?application.EnableEvents
If you get the answer True, then that's fine, there's something else wrong.
If it returns False, then type this in the immediate pane
application.EnableEvents=True
and try again changing cell A2.
If Events were enabled and nothing changed, you need to check that it's
doing what you intended. At the moment, since it's checking the cell being
changed is cell A2, to test it you need to change that cell. Change any other
cell and nothing will happen.
OK, let's say you do change cell A2, to say "dylan". The macro should
execute, and this line:
Worksheets(.Row).Name = .Value
will do its stuff which is to change the name of Sheet(2) to "dylan". ou
should see this on the sheet's tab. You won't see it if the sheet is hidden,
or it doesn't exist.
Why sheet(2)? Because .row is 2, because A2 is in row 2, and it's only when
A2 is changed that anything happens.
Just for clarity, because:
..row
is within the lines:
With Target
End with
it means:
Target.row.
(Target is the cell/range of cells being changed.)
Now change
Const WS_RANGE As String = "A2:A2"
to
Const WS_RANGE As String = "A3"
(btw, it doesn't need to be a constant)
Now the important part of the macro can only execute if cell A3 is changed,
but this is in row 3, so Sheet(3)'s name will be changed.
But is that what you intended?