+ Reply to Thread
Results 1 to 16 of 16

creating a sparkline using VBA

Hybrid View

  1. #1
    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.
    Good luck.

  2. #2
    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



    Sub ADD_SPARK_FOR_SELECTION()
     
    '
    Dim LINE As SparklineGroup
    Dim ws As Worksheet
    Dim rng As Range
    Dim Rng2 As Range
      
     
    
    Set ws = current.Sheet      ' KEEP GETTING OBJECT REQUIRED ERROR
     
     strow = Selection.Row
     ROWCT = Selection.Rows.Count
     stcol = Selection.Column
     colct = Selection.Columns.Count
     addr = Selection.Address
     
     
    ' IT IS MEANT TO USE THE SELECTION ON THE SHEET AND PUT RESULTS IN TWO ROWS BEFORE
     
     Set LINE = ws.Range(Cells(strow - 2, stcol), Cells(strow - 2, stcol + colct - 1)).SparklineGroups.Add(Type:=xlSparkLine, SourceData:=rng)
            
        
        Selection.SparklineGroups.Item(1).SeriesColor.ThemeColor = 5
        Selection.SparklineGroups.Item(1).SeriesColor.TintAndShade = -0.499984740745262
        Selection.SparklineGroups.Item(1).Points.Negative.Color.ThemeColor = 6
        Selection.SparklineGroups.Item(1).Points.Negative.Color.TintAndShade = 0
        Selection.SparklineGroups.Item(1).Points.Markers.Color.ThemeColor = 5
        Selection.SparklineGroups.Item(1).Points.Markers.Color.TintAndShade = -0.499984740745262
        Selection.SparklineGroups.Item(1).Points.Highpoint.Color.ThemeColor = 5
        Selection.SparklineGroups.Item(1).Points.Highpoint.Color.TintAndShade = 0
        Selection.SparklineGroups.Item(1).Points.Lowpoint.Color.ThemeColor = 5
        Selection.SparklineGroups.Item(1).Points.Lowpoint.Color.TintAndShade = 0
        Selection.SparklineGroups.Item(1).Points.Firstpoint.Color.ThemeColor = 5
        Selection.SparklineGroups.Item(1).Points.Firstpoint.Color.TintAndShade = 0.399975585192419
        Selection.SparklineGroups.Item(1).Points.Lastpoint.Color.ThemeColor = 5
        Selection.SparklineGroups.Item(1).Points.Lastpoint.Color.TintAndShade = 0.399975585192419
    End Sub
    Last edited by arlu1201; 04-18-2014 at 05:09 AM.

+ 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