Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Macro run time error

Replace Windows("Savings for Single Country Reporting.xls").Activate with
ThisWorkbook.Activate and it will work regardless of the actual name.
--
Best wishes,

Jim


"juliejg1" wrote:

I have created a macro in a workbook that is being used and run by other
people. Each person is naming their workbook something unique.
Unfortunately, that seems to cause problems for the macro. They receive a
run-time error 'subscript out of range'. The code were it is breaking is as
follows:

ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(2).Values = "=Formulas!R11C2"
ActiveWindow.Visible = False
Windows("Savings for Single Country Reporting.xls").Activate
ActiveSheet.ChartObjects("Chart 3").Activate
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(2).Values = "=Formulas!R17C2"
ActiveWindow.Visible = False
Windows("Savings for Single Country Reporting.xls").Activate
ActiveCell.Select

This is where the code breaks:

Windows("Savings for Single Country Reporting.xls").Activate


The workbook was renamed by it's new owner to 'LA Draft'. Several other
workbooks were also renamed to different names.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Macro run time error

Worked perfectly!! Thanks Jim

"Jim Jackson" wrote:

Replace Windows("Savings for Single Country Reporting.xls").Activate with
ThisWorkbook.Activate and it will work regardless of the actual name.
--
Best wishes,

Jim


"juliejg1" wrote:

I have created a macro in a workbook that is being used and run by other
people. Each person is naming their workbook something unique.
Unfortunately, that seems to cause problems for the macro. They receive a
run-time error 'subscript out of range'. The code were it is breaking is as
follows:

ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(2).Values = "=Formulas!R11C2"
ActiveWindow.Visible = False
Windows("Savings for Single Country Reporting.xls").Activate
ActiveSheet.ChartObjects("Chart 3").Activate
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(2).Values = "=Formulas!R17C2"
ActiveWindow.Visible = False
Windows("Savings for Single Country Reporting.xls").Activate
ActiveCell.Select

This is where the code breaks:

Windows("Savings for Single Country Reporting.xls").Activate


The workbook was renamed by it's new owner to 'LA Draft'. Several other
workbooks were also renamed to different names.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Macro run time error

I'm always glad to help. Having received my share of help from this group, I
feel good being able to contribute.
--
Best wishes,

Jim


"juliejg1" wrote:

Worked perfectly!! Thanks Jim

"Jim Jackson" wrote:

Replace Windows("Savings for Single Country Reporting.xls").Activate with
ThisWorkbook.Activate and it will work regardless of the actual name.
--
Best wishes,

Jim


"juliejg1" wrote:

I have created a macro in a workbook that is being used and run by other
people. Each person is naming their workbook something unique.
Unfortunately, that seems to cause problems for the macro. They receive a
run-time error 'subscript out of range'. The code were it is breaking is as
follows:

ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(2).Values = "=Formulas!R11C2"
ActiveWindow.Visible = False
Windows("Savings for Single Country Reporting.xls").Activate
ActiveSheet.ChartObjects("Chart 3").Activate
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(2).Values = "=Formulas!R17C2"
ActiveWindow.Visible = False
Windows("Savings for Single Country Reporting.xls").Activate
ActiveCell.Select

This is where the code breaks:

Windows("Savings for Single Country Reporting.xls").Activate


The workbook was renamed by it's new owner to 'LA Draft'. Several other
workbooks were also renamed to different names.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Macro Run-time error shirley_kee Excel Discussion (Misc queries) 1 May 3rd 06 09:50 PM
Macro time out error mike b Excel Worksheet Functions 1 December 10th 05 05:21 PM
Macro-Run-time error '6' Dave Y[_2_] Excel Programming 6 August 27th 03 02:22 AM


All times are GMT +1. The time now is 06:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"