![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 14
|
Hello All,
I am trying to create a copy of an Excel worksheet using the copy method in Visual Basic and am getting the following error message: "Run-time error 1004: Copy method of worksheet class failed" I have reduced my code to something as simple as the following just to debug this problem. --- Private Sub CommandButton1_Click() Worksheets("Sheet1").Copy after:=Worksheets(Worksheets.Count) End Sub --- This code works perfectly well on my machine at home running Excel 98, but gives the above err mesg on my machine at work running Excel '97. How do I fix this? I'd really appreciate your help. Thanks! Manish |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi
These are both shots in the dark... Better than no shot at all? Anyway, try these two things first. For your command button set the "take focus on click" property to false. Also, place this line of code before your copy method. Range("A1").Activate Doubt it will help but who knows... Tom |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|