I'm having trouble selecting parts of two different lines in a sub.
My sub must create a chart with these lines a DataSource
, and the number of the second line is an argument of the procedure. CompteLigneDebut
and CompteColonnefin
are functions that I defined earlier, they return an integer.
Here's the part that causes the issue, the specific line that causes an error is set x...
:
Sub test(ligne As Integer)
Dim graphe As Chart
Dim x As Range
Set graphe = Charts.Add
graphe.ChartType = xlColumnClustered
Set x = Application.Union(Range(Cells(ligne, 2), Cells(ligne, CompteColonneFin)), Range(Cells(CompteLigneDebut, 2), Cells(CompteLigneDebut, CompteColonneFin - 1)))
graphe.SetSourceData (x)
Thank you for your help/advice
The
Union
looks ok and the code below works fine for me. I think one of your functions is the problem.Try splitting the
Application.Union
line into smaller bits. Then check what values the functions return.