Sparklines

dpotta

New Member
Joined
Aug 16, 2011
Messages
29
9


Longshot:

This is a screen shot of part of a dynamic dashboard. Is there a method, VBA or otherwise for hiding the sparkline if the value in the cell to its left is zero?

Many thanks

D
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi,

The picture didn't make it. However, something like this might work:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    Application.EnableEvents = False
    On Error GoTo err
    If Not Intersect(Target, Columns("I:I")) Is Nothing Then
        If Target = 0 Then
            Target.Offset(0, 1).SparklineGroups.Clear
        Else
            Target.Offset(0, 1).SparklineGroups.Add Type:=xlSparkLine, _
                SourceData:=Target.Offset(0, -2).Resize(1, 3).Address
        End If
    End If
err:
    Application.EnableEvents = True
End Sub
I have assumed the possible zero value will be in column I and that the sparklines data will be in columns G to I and the sparklines in J.
If the value in column I is changed then it inserts sparklines if the value is non-zero and deletes them otherwise.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top