ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why does copy after worksheets command not work on some computers (https://www.excelbanter.com/excel-programming/353599-why-does-copy-after-worksheets-command-not-work-some-computers.html)

IanRC

Why does copy after worksheets command not work on some computers
 
I have written a VBA macro for an Excel 2003 workbook. Amongst other things,
at the end of the month it is intended to copy the most recent monthly sheet
and add it as a fresh copy as the new month's sheet for editing.

The weird thing is that, although this works fine on my laptop and most
other computers I have tried it on, it will not work on my desktop computer,
even if I copy exactly the same file across from one to the other.

Grateful for any pointers

Thx

Ian



Norman Jones

Why does copy after worksheets command not work on some computers
 
Hi Ian,

I think that you would need to post the relevant portion of your code.

You should also explain what you mean by:

it will not work on my desktop computer.


Does the code produce an error or merely not perform as you expect?


---
Regards,
Norman



"IanRC" wrote in message
...
I have written a VBA macro for an Excel 2003 workbook. Amongst other
things,
at the end of the month it is intended to copy the most recent monthly
sheet
and add it as a fresh copy as the new month's sheet for editing.

The weird thing is that, although this works fine on my laptop and most
other computers I have tried it on, it will not work on my desktop
computer,
even if I copy exactly the same file across from one to the other.

Grateful for any pointers

Thx

Ian





IanRC

Why does copy after worksheets command not work on some comput
 
Norman

Thanks. The relevant code is as follows:

' Add new sheet and title as next month
SPosition = Sheets.Count
.....
Sheets(SPosition).Select
Sheets(SPosition).Copy After:=Sheets(SPosition) 'adds a new sheet

On my laptop this last line inserts the a copy of the last sheet in the
spreadsheet after the sheet that was previously the last sheet. On my
desktop the macro just stops executing and exits at this point without
inserting the new sheet.

Sorry I was not clearer before

Ian



"Norman Jones" wrote:

Hi Ian,

I think that you would need to post the relevant portion of your code.

You should also explain what you mean by:

it will not work on my desktop computer.


Does the code produce an error or merely not perform as you expect?


---
Regards,
Norman



"IanRC" wrote in message
...
I have written a VBA macro for an Excel 2003 workbook. Amongst other
things,
at the end of the month it is intended to copy the most recent monthly
sheet
and add it as a fresh copy as the new month's sheet for editing.

The weird thing is that, although this works fine on my laptop and most
other computers I have tried it on, it will not work on my desktop
computer,
even if I copy exactly the same file across from one to the other.

Grateful for any pointers

Thx

Ian






Norman Jones

Why does copy after worksheets command not work on some comput
 
Hi Ian,

SPosition = Sheets.Count
.....
Sheets(SPosition).Select
Sheets(SPosition).Copy After:=Sheets(SPosition) 'adds a new
sheet


Since you do not qualify any instance of Sheets, the code will be qualified
implicitly to relate to the active workbook. It may be that the active
workbook is not the required workbook, in which case a sheet is being added
to the wrong workbook.

Try, therefore, qualifying the above code with a named workbook, or a
variable set to the workbook.

If the workbook of interest is the active workbook, I can see no reason for
the shown code to fail to add the new sheet.


---
Regards,
Norman



"IanRC" wrote in message
...
Norman

Thanks. The relevant code is as follows:

' Add new sheet and title as next month
SPosition = Sheets.Count
.....
Sheets(SPosition).Select
Sheets(SPosition).Copy After:=Sheets(SPosition) 'adds a new
sheet

On my laptop this last line inserts the a copy of the last sheet in the
spreadsheet after the sheet that was previously the last sheet. On my
desktop the macro just stops executing and exits at this point without
inserting the new sheet.

Sorry I was not clearer before

Ian



"Norman Jones" wrote:

Hi Ian,

I think that you would need to post the relevant portion of your code.

You should also explain what you mean by:

it will not work on my desktop computer.


Does the code produce an error or merely not perform as you expect?


---
Regards,
Norman



"IanRC" wrote in message
...
I have written a VBA macro for an Excel 2003 workbook. Amongst other
things,
at the end of the month it is intended to copy the most recent monthly
sheet
and add it as a fresh copy as the new month's sheet for editing.

The weird thing is that, although this works fine on my laptop and most
other computers I have tried it on, it will not work on my desktop
computer,
even if I copy exactly the same file across from one to the other.

Grateful for any pointers

Thx

Ian








IanRC

Why does copy after worksheets command not work on some comput
 
Thanks Norman

Tried that but no luck. The strange thing is it works fine on my laptop,
just not on my desktop

Ian

"Norman Jones" wrote:

Hi Ian,

SPosition = Sheets.Count
.....
Sheets(SPosition).Select
Sheets(SPosition).Copy After:=Sheets(SPosition) 'adds a new
sheet


Since you do not qualify any instance of Sheets, the code will be qualified
implicitly to relate to the active workbook. It may be that the active
workbook is not the required workbook, in which case a sheet is being added
to the wrong workbook.

Try, therefore, qualifying the above code with a named workbook, or a
variable set to the workbook.

If the workbook of interest is the active workbook, I can see no reason for
the shown code to fail to add the new sheet.


---
Regards,
Norman



"IanRC" wrote in message
...
Norman

Thanks. The relevant code is as follows:

' Add new sheet and title as next month
SPosition = Sheets.Count
.....
Sheets(SPosition).Select
Sheets(SPosition).Copy After:=Sheets(SPosition) 'adds a new
sheet

On my laptop this last line inserts the a copy of the last sheet in the
spreadsheet after the sheet that was previously the last sheet. On my
desktop the macro just stops executing and exits at this point without
inserting the new sheet.

Sorry I was not clearer before

Ian



"Norman Jones" wrote:

Hi Ian,

I think that you would need to post the relevant portion of your code.

You should also explain what you mean by:

it will not work on my desktop computer.

Does the code produce an error or merely not perform as you expect?


---
Regards,
Norman



"IanRC" wrote in message
...
I have written a VBA macro for an Excel 2003 workbook. Amongst other
things,
at the end of the month it is intended to copy the most recent monthly
sheet
and add it as a fresh copy as the new month's sheet for editing.

The weird thing is that, although this works fine on my laptop and most
other computers I have tried it on, it will not work on my desktop
computer,
even if I copy exactly the same file across from one to the other.

Grateful for any pointers

Thx

Ian










All times are GMT +1. The time now is 06:02 PM.

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