VBA - Sparkline SourceData to reference another Sheet using Range(Cells method

goodysgotacuda

Board Regular
Joined
Jun 27, 2014
Messages
51
Currently I have a pre-existing sparkline that references data from another sheet. Manually, this process works just fine, however I am strugging to convert the process to vba.

I need to convert it to VBA because my #of rows changes and it needs to recognize that on it's own.


I have the following code that I am using to try to reference the changing #of rows, on another sheet. This code within the "Temperature" sheet works fine when I remove the "Sheets("Temperature"). portion of the code.




I am looking to see if I can add the sheet reference to the range, somehow similary to how I have it below. The code shown errors out.


Rich (BB code):
Sheets("Temperature").select

   With ActiveSheet
        LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
        LastColumn = .Cells(2, .Columns.Count).End(xlToLeft).Column
    End With

Sheets("Results").select

    Range("B4:J12").Select
    ActiveCell.SparklineGroups.Item(1).Modify Location:=Range("$B$4"), _
        SourceData:=Sheets("Temperature").Range(Cells(2, 2), Cells(LastRow, 2)).Address
    Range("B4:J12").Select
    Selection.End(xlUp).Select
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,214,606
Messages
6,120,490
Members
448,967
Latest member
visheshkotha

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