Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
run macro after paste
Is it possible to run a macro after pasting some data onto a worksheet
|
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
run macro after paste
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. K wrote: Is it possible to run a macro after pasting some data onto a worksheet -- Dave Peterson |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
run macro after 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 On Mon, 27 Oct 2008 12:28:01 -0700, K wrote: Is it possible to run a macro after pasting some data onto a worksheet |
#4
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
run macro after paste
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 "Gord Dibben" wrote: 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 On Mon, 27 Oct 2008 12:28:01 -0700, K wrote: Is it possible to run a macro after pasting some data onto a worksheet |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
PLEASE help with cut/paste macro | Excel Discussion (Misc queries) | |||
Cut and Paste Macro | Excel Discussion (Misc queries) | |||
Macro needed to Paste Values and prevent Macro operation | Excel Discussion (Misc queries) | |||
Macro needed to Paste Values and prevent Macro operation | Excel Discussion (Misc queries) | |||
Cut&Paste Macro | Excel Worksheet Functions |