+ Reply to Thread
Results 1 to 2 of 2

Sub or Function not defined

  1. #1
    Registered User
    Join Date
    02-14-2011
    Location
    Midwest, USA
    MS-Off Ver
    Excel 2003
    Posts
    5

    Sub or Function not defined

    Hello all,

    I am sure this is a simple fix seeing as I am completely new at this. I have recorded a macro in which I am using solver. I want to be able to copy this code for multiple rows and put the code onto a command button so I can click the button and feel good about how smart I am. (Or rather how smart you are for helping. XD)

    Anyway, I tried testing the macro as soon as I created it and got the error Compile Error: Sub or Function not defined. I have not had this problem with recording macros in the past. Could someone tell me what I need to change and why I need to change it so I can learn from this experience?

    Thanks!!

    The code from the macro is as follows:


    Please Login or Register  to view this content.

    After the error The very first line of the code is highlighted -- Sub Macro1().

    Any and all help is appreciated! Thanks!I figured it out... I needed to check the box in references in VBA to Solver.
    Last edited by sooners885; 02-14-2011 at 04:49 PM. Reason: Solved

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Sub or Function not defined, VBA Help!

    Microsofts information about Solver

    Compile Error: Sub or Function not defined.
    To reference the Microsoft Excel Solver add-in for macros in your workbook, use the following steps:
    Open your workbook.
    On the Tools menu, point to Macro, and then click Visual Basic Editor.
    On the Tools menu, click References.
    In the Available References list, click to select the Solver.xls check box, and then click OK.

    Note If you do not see Solver.xls in the Available References list, click Browse. In the Add Reference dialog box, locate and select the Solver.xla file, and then click Open. The Solver.xla file is typically found in the C:\Program Files\Microsoft Office\Office\Library\Solver subfolder.
    You are now ready to use the Microsoft Excel Solver functions in a VBA macro.
    HTH

    Alf

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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