Sub LastCellInRow()
Sheets("Data").Select
Static myDataRange As Range
Dim MyCell As String
For i = 1 To 16
If [N9].Offset(0, i).Value = 0 Then
Else
MyCell = [N9].Offset(0, i).Address(rowabsolute:=False, columnabsolute:=False)
End If
Next i
ActiveSheet.ChartObjects(1).Activate
ActiveChart.SetSourceData Source:=Sheets("Data").Range("K9:K16,N9:" & MyCell & 16), PlotBy:= _
xlRows
End Sub
This works, however, I am trying to include the following as the source data:
=Data!$K$9:$K$16,Data!$N9:$whatever$16 this will always be row 16.
Basically it is two ranges that need to be selected and the last part of the last range is dependant upon if there are values in Row 9, but it will always include up until row 16.