Results 1 to 8 of 8

For Next Loop

Threaded View

  1. #5
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: For Next Loop

    Without wanting to sound totally stupid, how would I set calculation to manual (or is that what you meant by stepping through the code...) I'm really not so familiar with VBA, I tried stepping through the code but not really sure what I'm looking for to be totally honest.

    The code is basically supposed to change the data source for the charts from the name of the original workbook to the name of the new workbook but when I run it, I just get the hour glass and the main Workbook hangs (not responding). I'm unsure what is causing the problem though.

        For Each ws In ActiveWorkbook.Worksheets
            For Each oChart In ws.ChartObjects
                For Each mySrs In oChart.Chart.SeriesCollection
                    mySrs.Formula = WorksheetFunction.Substitute(mySrs.Formula, "'Original Workbook Name.xlsm'", "'New Workbook Name.xlsx'")
                Next
            Next
        Next ws
    The error I get relates to the line in red and is a run-time error '1004', telling me to verify your formula contains a valid path, workbook, range name and cell reference.

    My source series name is:

    =SERIES(" Total Forecast",{"M1","M2","M3","M4","M5","M6","M7","M8","M9","M10","M11","M12"},'Original Workbook Name.xlsm'!My_Forecast,1)
    and I'm trying to change it to:

    =SERIES(" Total Forecast",{"M1","M2","M3","M4","M5","M6","M7","M8","M9","M10","M11","M12"},'New Workbook Name.xlsx'!My_Forecast,1)
    Not sure if that helps to explain the problem?
    Last edited by HangMan; 09-07-2015 at 01:57 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Find function in nested loop breaking down - not on first time through loop
    By adamstarr12 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-14-2014, 09:32 AM
  2. Find function in nested loop breaking down - not on first time through loop
    By adamstarr12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-07-2014, 04:59 PM
  3. HOW TO: Pause loop, fix error on a popup UserForm, continue loop
    By AndyMachin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-19-2014, 04:37 PM
  4. Loop through multiple files and call macros (but unable to loop)
    By ryanpetersen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-23-2014, 12:04 PM
  5. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  6. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM
  7. Replies: 0
    Last Post: 07-20-2010, 11:42 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1