Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Error when doing a paste

This is a really simple problem to reproduce, but I can't see what I am
doing wrong. I have the following two functions in my workbook:

In Module1
Function MySum(arg1 As Double, arg2 As Double) As Double
MySum = arg1 + arg2
End Function

In Sheet1
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
addr = Target.Address
Sheet3.Range(addr).Formula = Target.Formula
If (Err.Number < 0) Then
MsgBox Err.Number & " - " & Err.Description
End If
End Sub

If I type =MySum(a7, b7) into cell A2 of Sheet1, I end up with the same
formula in cell A2 of Sheet3. Perfect. If I copy that formula from A2
on Sheet1 into B2 on Sheet1, the Worksheet_Change function fails. The
line
Sheet3.Range(addr).Formula = Target.Formula
gives error 1004 - Application-defined or object-defined error. There
is no formula in Sheet3!B2. If I then "edit" the cell Sheet1!B2, but
don't actually change anything, the SheetChange function works.

I don't get it. If I type the formula into the cell, it works. But,
if I copy/paste something that results in the same formula, then it
fails. What is it about the copy/paste that would cause that line to
fail?

thanks,
Jaimie

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Error when doing a paste

Backslider,

I've spent half an hour looking at this. I can reproduce the problem (XL
03) but I can't figure out the cause.

I notice that if I drag the fill handle using the mouse, it works fine, but
when I copy and paste, it fails as you describe.

Good luck.

Doug

"Backslider" wrote in message
ups.com...
This is a really simple problem to reproduce, but I can't see what I am
doing wrong. I have the following two functions in my workbook:

In Module1
Function MySum(arg1 As Double, arg2 As Double) As Double
MySum = arg1 + arg2
End Function

In Sheet1
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
addr = Target.Address
Sheet3.Range(addr).Formula = Target.Formula
If (Err.Number < 0) Then
MsgBox Err.Number & " - " & Err.Description
End If
End Sub

If I type =MySum(a7, b7) into cell A2 of Sheet1, I end up with the same
formula in cell A2 of Sheet3. Perfect. If I copy that formula from A2
on Sheet1 into B2 on Sheet1, the Worksheet_Change function fails. The
line
Sheet3.Range(addr).Formula = Target.Formula
gives error 1004 - Application-defined or object-defined error. There
is no formula in Sheet3!B2. If I then "edit" the cell Sheet1!B2, but
don't actually change anything, the SheetChange function works.

I don't get it. If I type the formula into the cell, it works. But,
if I copy/paste something that results in the same formula, then it
fails. What is it about the copy/paste that would cause that line to
fail?

thanks,
Jaimie



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Error when doing a paste


Doug Glancy wrote:
Backslider,

I've spent half an hour looking at this. I can reproduce the problem (XL
03) but I can't figure out the cause.

I notice that if I drag the fill handle using the mouse, it works fine, but
when I copy and paste, it fails as you describe.

Good luck.


Doug,

Thanks for looking into it.

This is a simplified example of what happens in our commercial
application (using VSTO 2003), so the "drag" workaround isn't going to
work. I don't think it is feasible to tell the customers that they
can't copy/paste.

If I could come up with some kind of code workaround to get Excel out
of whatever state it is in that it doesn't let you put the UDF into a
cell, that would be viable.

Jaimie

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Error when doing a paste

Jaimie,

I wasn't suggesting it as a workaround, for the reasons you mentioned. I
just thought it was worth mentioning - especially since I had nothing else
to offer <g.

Doug

"Backslider" wrote in message
oups.com...

Doug Glancy wrote:
Backslider,

I've spent half an hour looking at this. I can reproduce the problem (XL
03) but I can't figure out the cause.

I notice that if I drag the fill handle using the mouse, it works fine,
but
when I copy and paste, it fails as you describe.

Good luck.


Doug,

Thanks for looking into it.

This is a simplified example of what happens in our commercial
application (using VSTO 2003), so the "drag" workaround isn't going to
work. I don't think it is feasible to tell the customers that they
can't copy/paste.

If I could come up with some kind of code workaround to get Excel out
of whatever state it is in that it doesn't let you put the UDF into a
cell, that would be viable.

Jaimie



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
Paste error Alan[_9_] Excel Discussion (Misc queries) 0 December 17th 07 04:43 PM
Paste value error PJG Excel Discussion (Misc queries) 1 November 24th 06 02:07 PM
Cut and Paste using Macro gives paste special method error Lourens Pentz Excel Programming 3 November 21st 04 10:42 PM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM
Paste Error Marishah Warren Excel Programming 1 December 17th 03 08:31 AM


All times are GMT +1. The time now is 09:01 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"