Results 1 to 8 of 8

Thread: Sub or Function Not Defined

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    5

    Smile Sub or Function Not Defined

    Hi,

    I am new to VBA programming and trying to write some code.

    I wrote the following code.But when I run it, I get an error:

    Compile Error:
    Sub or function not defined

    The highlighted code is: Run_Start

    Code:
    Sub Update_From_Local()
    
        Clock_Start
        RunAllfunction
        Clock_Stop
    
    End Sub
    
    Sub RunAll()
    'Application.ScreenUpdating = False
        Run_Start
        PasteDown ("SalesOrders")
        PasteDown ("SupplyOrders")
        PasteDown ("Inventory")
        Stack ("DemandSupply")
        Sort3 ("DemandSupply"), ("RecordType"), ("ItemCode"), ("HARD_Date")
        PasteDownN ("DemandSupply"), 2
        Sort2 ("DemandSupply"), ("ItemCode"), ("HARD_Cumulative")
        PasteDownN ("DemandSupply"), 3
        Sort3 ("DemandSupply"), ("RecordType"), ("ItemCode"), ("FIFO_Date")
        PasteDownN ("DemandSupply"), 4
        Sort2 ("DemandSupply"), ("ItemCode"), ("FIFO_Cumulative")
        PasteDownN ("DemandSupply"), 5
        Run_Stop
        Sheets("Menu").Select
    'Application.ScreenUpdating = True
    End Sub
    Could anyone tell me why? What have I done wrong or missed?

    Appreciate any help I can get, still learning this stuff.

    Regards

    Bill

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Sub or Function Not Defined

    Hi..

    The error is clearly saying about the problem. That sub or function(named "Run_Start") is not defined or VB can't find the definition of it(body of that function/sub). So, check whether you have defined that function or not. If not, you can define it. Otherwise, check for spelling mistakes.


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Sub or Function Not Defined

    Moved To Office Development (which is the forum section for any questions related to VBA programming )

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    5

    Re: Sub or Function Not Defined

    Thanks akhileshbc for the advice, now need to look at this more closely if this is missing.

    I have read in the Microsoft help that it can be the reference, but when I review this, the "Reference" is grayed out, how to fix this?

    Regards

    Bill

  5. #5
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Sub or Function Not Defined

    Bstafford

    Your post shows code for Sub RunAll()

    Do you also have code for Sub Run_Start()
    (or is it named RunStart, which is different)

    Spoo

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    5

    Re: Sub or Function Not Defined

    Hi Spoo,

    There is no other sub for Run_Start(), but only RunAll(),
    maybe you are right and need to change the name. Thanks
    for the reply, will try a few things again and let you know.

    Bill

  7. #7
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Sub or Function Not Defined

    Bill

    If that is the case, then why do you have these lines of code?
    Code:
    Sub RunAll()
        'Application.ScreenUpdating = False
        Run_Start
        PasteDown ("SalesOrders")
        PasteDown ("SupplyOrders")
        PasteDown ("Inventory")
        Stack ("DemandSupply")
        Sort3 ("DemandSupply"), ("RecordType"), ("ItemCode"), ("HARD_Date")
        PasteDownN ("DemandSupply"), 2
        Sort2 ("DemandSupply"), ("ItemCode"), ("HARD_Cumulative")
        PasteDownN ("DemandSupply"), 3
        Sort3 ("DemandSupply"), ("RecordType"), ("ItemCode"), ("FIFO_Date")
        PasteDownN ("DemandSupply"), 4
        Sort2 ("DemandSupply"), ("ItemCode"), ("FIFO_Cumulative")
        PasteDownN ("DemandSupply"), 5
        Run_Stop
        Sheets("Menu").Select
        'Application.ScreenUpdating = True
    End Sub
    Spoo

  8. #8
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Sub or Function Not Defined

    and additionally, do you have those functions declared somewhere.
    Clock_Start
    RunAllfunction
    Clock_Stop
    Especially the "RunAllfunction" sounds like a namingproblem.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

Posting Permissions

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



Click Here to Expand Forum to Full Width