+ Reply to Thread
Results 1 to 16 of 16

creating a sparkline using VBA

  1. #1
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    creating a sparkline using VBA

    Hi there,

    I'm trying to create a sparkline using VBA(just testing it out for fun)

    Please Login or Register  to view this content.
    I keep getting stuck at the word "Type" in the codeline. Error is on "Expression"

    Has anybody had any experience using sparkline in VBA? The code comes from some website, but I have tried to modify it to suit my needs.

    Any ideas?
    Attached Files Attached Files
    Last edited by Lifeseeker; 02-06-2012 at 09:44 AM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: creating a sparkline using VBA

    You need a = after the "Type:", but I have no idea about sparklines!

  3. #3
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: creating a sparkline using VBA

    Please Login or Register  to view this content.
    should do it.
    Good luck.

  4. #4
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: creating a sparkline using VBA

    Quote Originally Posted by OnErrorGoto0 View Post
    Please Login or Register  to view this content.
    should do it.
    I'm getting "object required" error

    Please Login or Register  to view this content.
    Any ideas?
    Attached Files Attached Files

  5. #5
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: creating a sparkline using VBA

    What is WSL? I assumed it was the codename of your worksheet.

  6. #6
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: creating a sparkline using VBA

    Quote Originally Posted by OnErrorGoto0 View Post
    What is WSL? I assumed it was the codename of your worksheet.
    Oops, I think it's supposed to be the name of the worksheet.

    Anyhow, I'm getting a different error now

    "object variable or With block variable not set.

    Any ideas?

    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: creating a sparkline using VBA

    Same problem - you have not assigned anything to ws. You need a statement like
    Please Login or Register  to view this content.
    for example.

  8. #8
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: creating a sparkline using VBA

    still no luck with it hmm.

    Please Login or Register  to view this content.

    I wonder if the LINE setup is even correct. I'm new to the concept of doing a sparkline in VBA, but I just wanted to try it out using VBA(so that we don't have to use formula in the formula bar)

    Any ideas?
    Attached Files Attached Files

  9. #9
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: creating a sparkline using VBA

    "No luck" means what exactly? (I am on a phone so cannot review your file at present)

  10. #10
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: creating a sparkline using VBA

    Please Login or Register  to view this content.
    The target range made no sense given your data set.

  11. #11
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: creating a sparkline using VBA

    Please Login or Register  to view this content.
    I am not exactly positive on how the ranges work, but I guessed my around and thought if I put F2: H2 in there, it would mean to have it display the sparkline from F2 to H2?
    Attached Files Attached Files

  12. #12
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: creating a sparkline using VBA

    Sparklines appear in one cell each. If you want something larger, use a chart.
    I am not sure why you posted the same workbook again.

  13. #13
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: creating a sparkline using VBA

    It appears to be working.
    Please Login or Register  to view this content.
    When you said initially, the range doesn't make sense, which part of the code were your referring to?

  14. #14
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: creating a sparkline using VBA

    I was referring to your use of F2:H2 - which is why I changed it.

  15. #15
    Registered User
    Join Date
    04-17-2008
    Posts
    1

    Re: creating a sparkline using VBA

    I'd greatly appreciate any help ....


    this macro is meant to create a spark line for the selected range and put the results in the (row-2) range

    [result on this row.......]
    percent 11-Q1 11-Q2 11-Q3
    a.Zero 1% 2% 3%
    b.1-2 2% 3% 4%
    c.3-5 1% 2% 3%
    d.6-10 2% 3% 4%
    e.>10 1% 1% 1%

    I would select 1%...3% and the next 5 rows
    I would want to put the sparklines in [result on this row.......]

    thanks

    Mark



    Please Login or Register  to view this content.
    Last edited by arlu1201; 04-18-2014 at 05:09 AM.

  16. #16
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: creating a sparkline using VBA

    MarkJPawlik,

    Welcome to the forum. 2 pointers -

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. In order to put code tags, either type [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] at the end of it, OR you can highlight your code and click the # icon at the top of your post window.

    Also you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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