ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2003 "bug" (https://www.excelbanter.com/excel-programming/289353-excel-2003-bug.html)

Roger Lewis

Excel 2003 "bug"
 
I have an Excel vba program that works correctly in Excel
97, 2000 and 2002, but not in 2003.
A basic command of "Range("B1").select" followed
by "activesheet.paste" fails with the error...

Run-time error '1004':
Paste method of worksheet class failed

Here is the code that leads up to the error...

Sheets("Live").Select
Range("A65536").Select
Selection.End(xlUp).Select
Rows("2:" & ActiveCell.Row).Select
Selection.Sort Key1:=Range("A2"),
Order1:=xlAscending, Key2:=Range("C2") _
, Order2:=xlAscending, Header:=xlNo,
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
Range("A65536").Select
Selection.End(xlUp).Select
Last_Row_Number = ActiveCell.Row

Range("J2") = "=IF(OR(A2<A1,C2<C1),E2,E2+J1)"
Range("K2") = "=IF(AND(A2=A3,C2=C3),0,J2)"
Range("J2:K2").Copy
Range("J2:K" & Last_Row_Number).Select
ActiveSheet.Paste

Sheets("Live").Select
Columns("K:K").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<0",
Operator:=xlAnd

Columns("A:A").Select
Selection.Copy
Sheets("Live_byDay").Select
'the code fails here by not being able to select a cell
and then paste the contents of column A copied from
another sheet
Range("B1").Select
ActiveSheet.Paste
Application.CutCopyMode = False

The code works correctly in previous versions of Excel,
so I'm going to guess that it is a "bug". Does anyone
know whether this is the case? Or have a solution?
I have another Excel program where similar lines of code
creates the same error (but only in Excel 2003).

David

Excel 2003 "bug"
 
I have 2003, so I thought I would try a couple of simple
copy and pastes. I did two, one on the same sheet and a
second to another sheet and they both worked. I am not
working with yur data, etc., so I am not sure what is
happening, but worked ok in these sircumstances. Granted
they are very simple.

-----Original Message-----
I have an Excel vba program that works correctly in

Excel
97, 2000 and 2002, but not in 2003.
A basic command of "Range("B1").select" followed
by "activesheet.paste" fails with the error...

Run-time error '1004':
Paste method of worksheet class failed

Here is the code that leads up to the error...

Sheets("Live").Select
Range("A65536").Select
Selection.End(xlUp).Select
Rows("2:" & ActiveCell.Row).Select
Selection.Sort Key1:=Range("A2"),
Order1:=xlAscending, Key2:=Range("C2") _
, Order2:=xlAscending, Header:=xlNo,
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
Range("A65536").Select
Selection.End(xlUp).Select
Last_Row_Number = ActiveCell.Row

Range("J2") = "=IF(OR(A2<A1,C2<C1),E2,E2+J1)"
Range("K2") = "=IF(AND(A2=A3,C2=C3),0,J2)"
Range("J2:K2").Copy
Range("J2:K" & Last_Row_Number).Select
ActiveSheet.Paste

Sheets("Live").Select
Columns("K:K").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="<0",
Operator:=xlAnd

Columns("A:A").Select
Selection.Copy
Sheets("Live_byDay").Select
'the code fails here by not being able to select a cell
and then paste the contents of column A copied from
another sheet
Range("B1").Select
ActiveSheet.Paste
Application.CutCopyMode = False

The code works correctly in previous versions of Excel,
so I'm going to guess that it is a "bug". Does anyone
know whether this is the case? Or have a solution?
I have another Excel program where similar lines of code
creates the same error (but only in Excel 2003).
.



All times are GMT +1. The time now is 10:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com