run macro after paste

  • Thread starter Thread starter K
  • Start date Start date
Sure.

Just alt-f8, select the macro and click run.

If you mean you want to run a macro automatically after pasting, then probably
not.

Excel can run a _change event when a range changes, but it doesn't know if that
range changed because of the user typing or because of a paste.
 
It is possible using event code but "some data" needs clarifying.

Copying just data or formulas?

Pasting into one cell or a range of cells?

If a range of cells what would it be?

Variable or fixed range?

Code for one cell if not pasting a formula...................

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo stoppit
Application.EnableEvents = False
If Target.Address = "$A$2" And Not Target.HasFormula Then
MsgBox "a change has been made to A2"
'Call Macroname
End If
Application.CutCopyMode = False
stoppit:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP
 
Yes copying data from word - basically the sheet is protected to protect the
formulas, this is because the sheet is used by many users , the problem being
that when the word report (which has been exported from aanother program) is
pasted its propertys are locked therefore next time someone comes to use it
then the cells they need to delete & paste the new data in are protected.
Now I have my Formular to unprotect, unlock & re protect the cells but I
would like this to trigger automatically from the paste. At the moment it
triggers everytime someone clicks on the particular sheet which is OK but
not Ideal
 
Back
Top