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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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,214,879
Messages
6,122,065
Members
449,064
Latest member
scottdog129

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