ws.Copy: VBA sub just exits there - Excel XP SP3 issue?

Roopher

Board Regular
Joined
Jul 8, 2008
Messages
73
Hello!

Using Excel XP SP2, I wrote VBA that does a ws.Copy which works fine (copy a hidden template worksheet within a workbook). When I tried to run the VBA on three (professionally administrated) company Excel XP SP3 machines, the very ws.Copy line of the code caused the sub to bail out with no error message at all. Also, the ws.Copy method into a new workbook (meant as a data export feature) does not run - the same symptom.

Trying to pin down the problem, I manually recorded a simple macro from a clean workbook as follows:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 08/07/2008 by ME
'
ActiveCell.FormulaR1C1 = "Hello Friends!"
Range("B5").Select
Sheets("Sheet1").Select
Sheets("Sheet1").Copy Before:=Sheets(2)

MsgBox "Finished!"
End Sub

Under the Excel XP SP3 machine, the manual execution of the steps (when actually recording the macro) works. But when I run the macro itself, on the line with "Sheets("Sheet1").Copy Before:=Sheets(2)" the macro just exits with no error message or other anomalies. It simply exits (thats probably why I found nothing in Google or the Forum Search). Anyone has got an idea on this behaviour? Again, on the Excel XP SP2 system it runs through as expected.

Roopher
 
Last edited:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hello, this is me again, Roopher.

Can please, please someone just run the above macro code on a Excel XP SP3 machine, so I can further limit the number of causes of the issue? That would be very nice of you! And it really takes a minute only... Please help!!!

Here is the code again:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 08/07/2008 by ME
'
ActiveCell.FormulaR1C1 = "Hello Friends!"
Range("B5").Select
Sheets("Sheet1").Select
Sheets("Sheet1").Copy Before:=Sheets(2)

MsgBox "Finished!"
End Sub


Thank you all,


Roopher
 
Upvote 0
I don't have XP available.

Sheets("Sheet1").Copy Before:=Sheets(2)
to
Sheets("Sheet1").Copy Before:=Worksheets(2)

That is the only suggestion I have for now...
 
Upvote 0
Re: ws.Copy: VBA sub just exits there - Excel XP SP3 - Nobody?

Hi Tom,

thanks a lot for the suggestion. But since the steps in that macro work fine indeed when manually executed, but *not* when the recorded macro is actually run as a macro, the situation is still unclear to me. (Excel 2002/XP SP3)

Also, on my home Excel 2002/XP SP2 machine the code works.

Guessing from the poor response to my post, I assume that no one else has experienced my problem as described. Can I post 2 questions, still?

1.
Is it a known situation that a seqence of instructions runs through when recording them as macro, but not when the macro is being called from the Excel UI?

2.
What methodology would a experienced Excel developer suggest to find a malfunction's cause when a macro just bails out from execution in the middle of the code with no error message?


Best regards,

Roopher
 
Upvote 0
Re: ws.Copy: VBA sub just exits there - Excel XP SP3 - Nobody?

If you email your workbook too me I can trouble shoot a bit further. Have been successful to this point...:)
tstom@fuse.net
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top