How do I programmatically build a range?
MyRange = "A1:A" & LastActiveCell
--
HTH
Bob
(there's no email, no snail mail, but somewhere should be gmail in my addy)
"JudgeMental" wrote in message
...
I have a fixed range of cells (41) that I need to chart. The user may or
may
not fill all the final cells. I need to exclude these unused cells at the
end
from the chart.
Dim LastColReservedCell As Integer
Dim LastActiveCell As Integer
Dim MyRange As Range
LastActiveCell = 0
LastColReservedCell = 41
For Each c In Worksheets("Charts").Range _
("B1:B41").Cells
If c.Value < 1 Then
Blanks = Blanks + 1
Else
Blanks = Blanks
End If
Next
LastActiveCell = LastColReservedCell - Blanks
'Here is where the problem starts. Trying to build the range generates an
error 13.
MyRange = "A1:" + LastActiveCell
'If I can build a valid Range, I would like to use it as shown below:
ActiveChart.SetSourceData Source:=Sheets("Charts").Range(MyRange), PlotBy
_
:=xlColumns
'Using (MyRange) instead of ("A1:B41")
Is this possible?
Thank You for your help.
|