Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default running code after pasting data

I have a worksheet into which I paste a block of data. After pasting, I run
some VB code to do some editing, using the worksheet_change event. This
causes the code to run every time I make a change to the sheet, instead of
only when I do the paste.

I tried adding

If target.address = "$A$2" then

to the beginning of the procedure, but this causes the code to run only if I
paste a single value into cell A2, but not when I paste a block of data into
cells beginning with A2.

How can I make the code run only when I paste the block of data, and not on
every update to the worksheet?

Any suggestions would be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default running code after pasting data

If Not Application.Intersect(Target, Target.Parent.Range("A2")) Is Nothing
Then

will execute if A2 is included as part of any range size.
Not sure how to selectively run it based on pasting, etc. It it changes, it
will run.


"lallen" wrote in message
...
I have a worksheet into which I paste a block of data. After pasting, I

run
some VB code to do some editing, using the worksheet_change event. This
causes the code to run every time I make a change to the sheet, instead of
only when I do the paste.

I tried adding

If target.address = "$A$2" then

to the beginning of the procedure, but this causes the code to run only if

I
paste a single value into cell A2, but not when I paste a block of data

into
cells beginning with A2.

How can I make the code run only when I paste the block of data, and not

on
every update to the worksheet?

Any suggestions would be greatly appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default running code after pasting data

I couldn't get this to work. The code ran, regardless of what cell was
updated. But, with a fresh mind this morning, I did come up with the
following solution.

If InStr(target.Address, "$A$2") 0 Then

Thanks for your help.

"Tim Zych" wrote:

If Not Application.Intersect(Target, Target.Parent.Range("A2")) Is Nothing
Then

will execute if A2 is included as part of any range size.
Not sure how to selectively run it based on pasting, etc. It it changes, it
will run.


"lallen" wrote in message
...
I have a worksheet into which I paste a block of data. After pasting, I

run
some VB code to do some editing, using the worksheet_change event. This
causes the code to run every time I make a change to the sheet, instead of
only when I do the paste.

I tried adding

If target.address = "$A$2" then

to the beginning of the procedure, but this causes the code to run only if

I
paste a single value into cell A2, but not when I paste a block of data

into
cells beginning with A2.

How can I make the code run only when I paste the block of data, and not

on
every update to the worksheet?

Any suggestions would be greatly appreciated.




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
Why can't I use SUM when pasting HTML code into new sheet. Crosscatch Excel Worksheet Functions 1 January 9th 06 04:29 PM
Pasting on Filtered Data Sheets without pasting onto hidden cells CCSMCA Excel Discussion (Misc queries) 1 August 28th 05 01:22 PM
Check cell for data before running code Pat Excel Programming 1 January 12th 05 08:58 PM
Over-Eager code is pasting 3 times Stuart[_5_] Excel Programming 3 September 10th 03 07:30 PM


All times are GMT +1. The time now is 02:50 AM.

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"