+ Reply to Thread
Results 1 to 5 of 5

VBA Loop Will Not Stop.

Hybrid View

  1. #1
    Registered User
    Join Date
    09-18-2015
    Location
    london
    MS-Off Ver
    2010
    Posts
    18

    VBA Loop Will Not Stop.

    Hi,

    My attached code won't stop looping. It's probably something very small but I have been looking at this a while now and can't seem to find the solution.

    Would appreciate any help.

        b = cvsSrv.Reports.CreateReport(Info, Rep)
           If b Then
              Rep.Window.Top = 25000
              Rep.Window.Left = 25000
              Rep.Window.Width = 1
              Rep.Window.Height = 1
              Debug.Print Rep.SetProperty("Group", BGroup)
              Debug.Print Rep.SetProperty("Splits", "1;10;12-17;30;241;2000")
              b = Rep.ExportData("", 9, 0, True, True, True)
              Set wk = ThisWorkbook
              Sheet1.Cells(ReportRowstart, 1).PasteSpecial
              Rep.Quit
              ReportRowEnd = Sheet1.Range("A10000").End(xlUp).Row
              ReportRowstart = ReportRowEnd + 1
              If Not cvsSrv.Interactive Then cvsSrv.ActiveTasks.Remove Rep.TaskID
              Set Rep = Nothing
              End If
              Rep.Quit
              
       End If
          
          Next CurrentRow
           
        Set Info = Nothing
    thank you

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA Loop Will Not Stop.

    I think you need to show the entire loop too get the proper response. Your above code is missing the For statement for the CurrentRow.

  3. #3
    Registered User
    Join Date
    09-18-2015
    Location
    london
    MS-Off Ver
    2010
    Posts
    18

    Re: VBA Loop Will Not Stop.

    ' ReportRowstart = 1
                Startrow = 2
                EndRow = MaxRows
            
            For CurrentRow = Startrow To EndRow
            AgentGroup = Sheet2.Cells(CurrentRow, 9).Value
    
    
           b = cvsSrv.Reports.CreateReport(Info, Rep)
           If b Then
              Rep.Window.Top = 25000
              Rep.Window.Left = 25000
              Rep.Window.Width = 1
              Rep.Window.Height = 1
              Debug.Print Rep.SetProperty("Group", BGroup)
              Debug.Print Rep.SetProperty("Splits/Skills", "1;10;12-17;30;241;2000")
              b = Rep.ExportData("", 9, 0, True, True, True)
              Set wk = ThisWorkbook
              Sheet1.Cells(ReportRowstart, 1).PasteSpecial
              Rep.Quit
              ReportRowEnd = Sheet1.Range("A10000").End(xlUp).Row
              ReportRowstart = ReportRowEnd + 1
              If Not cvsSrv.Interactive Then cvsSrv.ActiveTasks.Remove Rep.TaskID
              Set Rep = Nothing
              End If
              Rep.Quit
             
       End If
          
          Next CurrentRow
           
    '    Set Info = Nothing
    thank you

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA Loop Will Not Stop.

    What is maxrows?

  5. #5
    Registered User
    Join Date
    09-18-2015
    Location
    london
    MS-Off Ver
    2010
    Posts
    18

    Re: VBA Loop Will Not Stop.

    MaxRows = Sheet2.Range("I10000").End(xlUp).Row
    EndRow = MaxRows
    StartRow = 2
    
    For CurrentRow = Startrow To EndRow
    thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. how to stop For Loop and Next
    By Anvuri in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-10-2014, 02:12 PM
  2. How to Stop a Do While Loop at a certain row??
    By jtemp57 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-27-2014, 09:53 AM
  3. [SOLVED] how to stop this loop....
    By vimalanathk in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-03-2013, 03:45 AM
  4. Loop Does Not Stop
    By ryanmorris in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-14-2011, 07:31 PM
  5. Can't get my loop to stop!!
    By berlinhammer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-31-2009, 03:04 AM
  6. Hot key to stop a LOOP
    By joopdog in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-09-2006, 02:51 PM
  7. Stop a loop
    By Matthew McManus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-11-2005, 04:55 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