Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
K K is offline
external usenet poster
 
Posts: 108
Default run macro after paste

Is it possible to run a macro after pasting some data onto a worksheet
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
K K is offline
external usenet poster
 
Posts: 108
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PLEASE help with cut/paste macro [email protected] Excel Discussion (Misc queries) 2 August 2nd 07 06:22 PM
Cut and Paste Macro M.A.Tyler Excel Discussion (Misc queries) 3 April 28th 07 02:50 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM
Cut&Paste Macro [email protected] Excel Worksheet Functions 5 April 8th 05 03:51 PM


All times are GMT +1. The time now is 04:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"