Excel 2010
i am attempting to update multiple sparklines with VBA for the first time.
First, I recorded a macro and it returned the following usable code:
I have 13 columns (E-Q) in a worksheet called 'Data'. On the active sheet, columns D,E,F,G contain sparkline groups from rows 9-22. Each cell's sparkline is one week worth of data (which is being sorted with a separate macro).
I couldn't find much out there to help with this, so I thought I would post and ask the question: Do you have suggestions to improve it?
Thank you
Francisco Shillander
i am attempting to update multiple sparklines with VBA for the first time.
First, I recorded a macro and it returned the following usable code:
Code:
Sub Macro1()
Range("D9:G9").Select
ActiveCell.SparklineGroups.Item(1).Modify Location:=Range( _
"$D$9,$E$9,$F$9,$G$9"), SourceData:= _
"Data!E2:E8,Data!E9:E15,Data!E16:E22,Data!E23:E29"
Range("D9,E9,F9,G9").Select
Range("G9").Activate
End Sub
I have 13 columns (E-Q) in a worksheet called 'Data'. On the active sheet, columns D,E,F,G contain sparkline groups from rows 9-22. Each cell's sparkline is one week worth of data (which is being sorted with a separate macro).
Code:
Sub UpdateSparklines()
Dim h As Integer
Dim i As Integer
Dim j As Integer
Dim Col As Variant
Dim DRange As String
Dim SRange As String
Dim Ar(1 To 13) As Variant
j = 1
For h = 5 To 17
Ar(j) = Chr(h + 64)
j = j + 1
Next
i = 9
For Each Col In Ar
DRange = "$D$" & i & ",$E$" & i & ",$F$" & i & ",$G$" & i
Range("D" & i & ":G" & i).Select
SRange = "Data!" & Col & _
"2:" & Col & "8,Data!" & Col & _
"9:" & Col & "15,Data!" & Col & _
"16:" & Col & "22,Data!" & Col & _
"23:" & Col & "29"
ActiveCell.SparklineGroups.Item(1).Modify Location:=Range(DRange), SourceData:=SRange
i = i + 1
Next
End Sub
I couldn't find much out there to help with this, so I thought I would post and ask the question: Do you have suggestions to improve it?
Thank you
Francisco Shillander