+ Reply to Thread
Results 1 to 7 of 7

Help with End Sub Error in Code

  1. #1
    Registered User
    Join Date
    07-17-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    3

    Help with End Sub Error in Code

    Hi I found this code which creates sparklines (small line charts) on a website (Can't find the website again). Whenever I try and run the code I get the following error: Compile Error Expected End Sub. I've searched a few forums but haven't been able to resolve what the issue is. The code is:
    Please Login or Register  to view this content.
    appreciate any help. Thx
    Last edited by likes_excel; 07-17-2013 at 01:10 PM. Reason: Added code tags per forum rules

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Help with End Sub Error in Code

    Please Login or Register  to view this content.
    Needs to be:
    Please Login or Register  to view this content.
    Please use code tags on your posts. Select your code and press the # button in the tool bar above.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Help with End Sub Error in Code

    likes,
    Welcome to the forum!
    Please use code tags with your code as per forum's rule.
    You have the sub and functions code mixed up.
    If you start with SUB, finish it with END SUB
    If you start with Function, you end with END FUNCTION
    Last edited by AB33; 07-17-2013 at 01:06 PM.

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Help with End Sub Error in Code

    Idk if that function is valid but try removing Sub Sparkline. The process is declared as a function immediately under it.

  5. #5
    Registered User
    Join Date
    07-17-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Help with End Sub Error in Code

    Hey Thanks everyone. I took out the Sub Sparkline (now it starts with the function) but how do I run it if it is not a Sub? I highlighted the entire function and hit F5 and it only gave me options to run other codes not the function itself. Thank you!

  6. #6
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Help with End Sub Error in Code

    Function return a single object/value etc so they have to be called from a Sub Procedure in a manner that can except the type of object returned.

    Meaning if it returns a number (integer, long, etc) it has to be called from a Sub expecting a number. It looks like your function returns a string.

  7. #7
    Registered User
    Join Date
    07-17-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Help with End Sub Error in Code

    Thank you XeRO Solus!!

+ 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. [SOLVED] Getting Error 1004 Object or Application Defined Error - Code to rearrange data
    By BlazzedTroll in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-10-2013, 12:10 PM
  2. [SOLVED] IF Exists or on Error Then - Skip Code- How to write code?
    By Jack7774 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-22-2013, 06:45 PM
  3. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 PM
  4. Protect/Unprotect code causing out of range error in code
    By Petrolcb41 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2010, 02:34 PM
  5. Error 424 Object Required Error when Using AddItem to ListBox Generated in Code
    By jclark419 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2010, 12:47 PM

Tags for this Thread

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