VBA to Check if a Cell Contains a Sparkline

ormy28

New Member
Joined
Dec 10, 2007
Messages
20
Office Version
  1. 365
Hi. I was wondering if there was a way to check whether a cell contains a sparkline using VBA? I was hoping there would be something like ActiveCell.HasSparkLine to check the active cell, but it appears not.

I have a spreadsheet that contains around 20 sheets, all containing numerous sparklines in column D. However, the rows that contain the sparklines is inconsistent across all the sheets. I has looking to use a loop, starting in D1 and moving down a cell at a time to the last row of data, checking if the cell contained a sparkline. If it does, the range of the sparkline would be amended using a variable.

The updating of the sparkline is straightforward enough, it's just the initial check as to whether the active cell contains a sparkline that is proving problematic.

Any help here would be greatly appreciated, thanks.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
To test if a cell contains a sparkline, you could try to tap into the SparklineGroups object's count property:

VBA Code:
If ActiveCell.SparklineGroups.Count Then
    Debug.Print "Sparkline Detected"
End If

Also, maybe you can get some idea's here to retrieve all sparklines.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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