Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Run Macro After Paste

Is there a way to run a macro after pasting information into a cell?

For example excel lets you run things when you open the workbook:

Private Sub Workbook_Open()
End Sub

Is there one for paste as well?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Run Macro After Paste

Paste trigs the Worksheet_change event, but it can't tell whether you pasted
or wrote something into the cell. Unless you copy-paste a range of multiple
cells, then she knows that multiple cells changed at once.

HTH. Best wishes Harald

"RigasMinho" skrev i melding
ups.com...
Is there a way to run a macro after pasting information into a cell?

For example excel lets you run things when you open the workbook:

Private Sub Workbook_Open()
End Sub

Is there one for paste as well?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Run Macro After Paste

Harald,
Not exhaustively tested, but seems if you check the .CutCopyMode in this
event, you can detect a Paste as opposed normal entry.

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox IIf(Application.CutCopyMode = xlCopy, "Pasted", "Normal Entry")
End Sub

NickHK

"Harald Staff" wrote in message
...
Paste trigs the Worksheet_change event, but it can't tell whether you

pasted
or wrote something into the cell. Unless you copy-paste a range of

multiple
cells, then she knows that multiple cells changed at once.

HTH. Best wishes Harald

"RigasMinho" skrev i melding
ups.com...
Is there a way to run a macro after pasting information into a cell?

For example excel lets you run things when you open the workbook:

Private Sub Workbook_Open()
End Sub

Is there one for paste as well?





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default Run Macro After Paste

Hi Nick

It seem to work well for copy-paste, but not for cut-paste, which counts as
two normal entries in a serie. Neat idea though.

Best wishes Harald



"NickHK" skrev i melding
...
Harald,
Not exhaustively tested, but seems if you check the .CutCopyMode in this
event, you can detect a Paste as opposed normal entry.

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox IIf(Application.CutCopyMode = xlCopy, "Pasted", "Normal Entry")
End Sub

NickHK

"Harald Staff" wrote in message
...
Paste trigs the Worksheet_change event, but it can't tell whether you

pasted
or wrote something into the cell. Unless you copy-paste a range of

multiple
cells, then she knows that multiple cells changed at once.

HTH. Best wishes Harald

"RigasMinho" skrev i melding
ups.com...
Is there a way to run a macro after pasting information into a cell?

For example excel lets you run things when you open the workbook:

Private Sub Workbook_Open()
End Sub

Is there one for paste as well?







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Run Macro After Paste

Harold,
After actually reading the help and seeing there are actually 3 values for
CutCopyMode, I thought would work:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Msg As String
Select Case Application.CutCopyMode
Case False
Msg = "Normal Entry"
Case xlCopy
Msg = "Pasted Copy"
Case xlCut
Msg = "Pasted Cut"
End Select
MsgBox Msg
End Sub

But xlCut is never fired and actually caused this event to fire twice. That
I could understand if there was a Cut (1 _Change) and a Paste (2 _Change),
but you are never (apparently) in CutCopyMode=xlCut for either operation,
both times =False. Seems a bit weird.

NickHK

"Harald Staff" wrote in message
...
Hi Nick

It seem to work well for copy-paste, but not for cut-paste, which counts

as
two normal entries in a serie. Neat idea though.

Best wishes Harald



"NickHK" skrev i melding
...
Harald,
Not exhaustively tested, but seems if you check the .CutCopyMode in this
event, you can detect a Paste as opposed normal entry.

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox IIf(Application.CutCopyMode = xlCopy, "Pasted", "Normal Entry")
End Sub

NickHK

"Harald Staff" wrote in message
...
Paste trigs the Worksheet_change event, but it can't tell whether you

pasted
or wrote something into the cell. Unless you copy-paste a range of

multiple
cells, then she knows that multiple cells changed at once.

HTH. Best wishes Harald

"RigasMinho" skrev i melding
ups.com...
Is there a way to run a macro after pasting information into a cell?

For example excel lets you run things when you open the workbook:

Private Sub Workbook_Open()
End Sub

Is there one for paste as well?











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default Run Macro After Paste

Weird indeed. Looks like something the programmers abandoned before it was
finished. To be useful, it would also need a fourth value; drag-drop of
cells or ranges.

Best wishes Harald

"NickHK" skrev i melding
...
Harold,
After actually reading the help and seeing there are actually 3 values for
CutCopyMode, I thought would work:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Msg As String
Select Case Application.CutCopyMode
Case False
Msg = "Normal Entry"
Case xlCopy
Msg = "Pasted Copy"
Case xlCut
Msg = "Pasted Cut"
End Select
MsgBox Msg
End Sub

But xlCut is never fired and actually caused this event to fire twice.
That
I could understand if there was a Cut (1 _Change) and a Paste (2 _Change),
but you are never (apparently) in CutCopyMode=xlCut for either operation,
both times =False. Seems a bit weird.

NickHK



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
copy multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro Steven Excel Programming 1 October 17th 05 08:56 AM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM
Cut and Paste using Macro gives paste special method error Lourens Pentz Excel Programming 3 November 21st 04 10:42 PM
Macro to Paste to specific line, and continue to Paste each time on next row not over tomkarakowski[_2_] Excel Programming 1 May 28th 04 06:50 PM
Macro to Copy/Paste then Paste to Next Line tomkarakowski Excel Programming 1 May 28th 04 01:19 AM


All times are GMT +1. The time now is 01:44 AM.

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

About Us

"It's about Microsoft Excel"