Dynamically updating Sparklines in VBA Code

Minerva7

New Member
Joined
Mar 24, 2019
Messages
16
Hello,

I have an Excel file, with multiple tabs, in which I pull in data (daily) using VBA. I use sparklines to show trends, and I usually do this part of it manually (basically extending the sparkline to the next cell, including cells that have a value of zero). I'm looking for a way to make this as efficient as possible by writing in more VBA code that will automatically extend the sparkline to the next cell containing data. Can anyone help? Thanks in advance.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi Minerva,
try the macro recorder, when I manually change a sparkline I get:
VBA Code:
ActiveCell.SparklineGroups.Item(1).Modify Location:=Range("$L$3"), SourceData:="E3:K3"
And from the microsoft site:
SparklineGroup.Modify method (Excel) ->
VBA Code:
Range("A1:A4").Select 
ActiveCell.SparklineGroups.Item(1).Modify Location:=Range("$A$1:$A$3"), SourceData:="Sheet1!B1:D3"
You can use parts of that code to add to your code, first inserting the data and after that setting the source of the various spark charts.
Hope that helps,
Koen
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,453
Members
452,514
Latest member
cjkelly15

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