+ Reply to Thread
Results 1 to 6 of 6

"invalid next control variable reference" While trying to compile.

  1. #1
    Registered User
    Join Date
    09-01-2022
    Location
    Holstebro, Denmark
    MS-Off Ver
    Office 365
    Posts
    9

    Question "invalid next control variable reference" While trying to compile.

    I'm trying to make a Multiple Solver using VBA in excel to make my work go faster.
    I cant seem to figure out what i'm doing wrong even tho this should be super simple. (relative new to VBA and Excel)
    I think the error has something to do with my "For i" and my "Next i"=?
    Hope someone can hlep me out!

    PHP Code: 
    Sub MultipleSolver()
    Dim i As Integer
    Dim o 
    As Integer
    ActivateWorkbook
    .ActivateSheet.Activate
    For 36 To 37
    For 39 To 51
    SolverReset
    SolverOk SetCell
    :="$C$" iMaxMinVal:=3ValueOf:=0ByChange:="$H$" o
    SolverSolve True
    Next i
    Next o

    End Sub 
    Last edited by Juhl94; 09-01-2022 at 10:25 AM.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,791

    Re: "invalid next control variable reference" While trying to compile.

    The Next o line needs to go before the Next i

  3. #3
    Registered User
    Join Date
    09-01-2022
    Location
    Holstebro, Denmark
    MS-Off Ver
    Office 365
    Posts
    9

    Re: "invalid next control variable reference" While trying to compile.

    Awsome! didnt realise that...
    Sadly it now says "Object required"?

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,791

    Re: "invalid next control variable reference" While trying to compile.

    On which line?
    You can also get rid of this line as it doesn't do anything
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-01-2022
    Location
    Holstebro, Denmark
    MS-Off Ver
    Office 365
    Posts
    9

    Re: "invalid next control variable reference" While trying to compile.

    It worked when i removed that line! i just tryed to follow a youtube vid! Thanks alot!

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,791

    Re: "invalid next control variable reference" While trying to compile.

    Glad to help & thanks for the feedback.
    Just noticed that it should actually have been
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    but as I said it's not needed.

+ 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. Replies: 11
    Last Post: 12-19-2019, 04:46 PM
  2. [SOLVED] Why am i getting "Compile error: Invalid ReDim"
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-05-2017, 11:58 AM
  3. [SOLVED] VBA Noob, "Compile Error: Invalid Use of Property" On First line of Code (great..)
    By tvwright in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 10-20-2015, 05:00 PM
  4. Changed code and now get " Invalid next control variable reference
    By b_rianv in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-31-2014, 05:19 PM
  5. Compile error: Invalid Next control varibale reference
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-03-2014, 06:51 AM
  6. [SOLVED] Debugging - Compile error: Invalid Next control variable reference
    By xxgirlinbluexx in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-26-2013, 08:14 AM
  7. Compile Error: Invalid Next Control Variable Reference
    By mlegge04 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-25-2012, 02:38 PM

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