我制作了一些迷你图,我试图引用源数据的范围。问题是每个月都会添加范围。我需要能够使用已知第一个单元格的范围,直到找到一个值.Offset(0,-1)
Dif wb As Workbook
Dif ws As Worksheet
Set wb = Workbooks("HardDrive location")
Set ws = wb.Worksheets("Sheet1")
wb.ws.Range.Rows(4).Cells.Find("XXX").Offset(0, 1).Select
Selection.SparklineGroups.Add Type:=xlSparkLine, SourceData:= Range("D4", wb.ws.Range.Rows(4).Find("XXX").Offset(0,-1))
'Other Parameters are below, but there aren't any problems past this point'
不确定如何让它发挥作用。任何帮助,将不胜感激。
答案 0 :(得分:0)
<强>编辑:强>
Sub Test()
Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Range
Set wb = ActiveWorkbook
Set ws = wb.Worksheets("Sheet1")
Set rng = ws.Rows(4).Cells.Find("XXX").Offset(0, -1)
Range(rng.Offset(0, 1).Address).SparklineGroups.Add Type:=xlSparkLine, SourceData:=Range("D4" & ":" & rng.Address).Address
End Sub