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:

Roopher

Board Regular
Joined
Jul 8, 2008
Messages
73
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
 

Tom Schreiner

Well-known Member
Joined
Mar 18, 2002
Messages
6,867
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...
 

Roopher

Board Regular
Joined
Jul 8, 2008
Messages
73
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
 

Tom Schreiner

Well-known Member
Joined
Mar 18, 2002
Messages
6,867
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
 

Forum statistics

Threads
1,081,530
Messages
5,359,347
Members
400,524
Latest member
Excelbat

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top