getting out of range error on red line...seems like this should work to me
[vba]Sub STEP5_Trending()
Dim LCol As Integer
Dim i As Integer
Dim dataRng(1 To 5) As Range
Dim title(1 To 5) As String
ActiveWorkbook.Sheets("Daily Totals").Activate
Range("A1").Select
For i = 2 To 40
If Cells(2, i).Value = "" Then
LCol = i
Exit For
End If
Next i
With ActiveSheet
Set dataRng(1) = Range(.Cells(1, 1), .Cells(13, LCol))
Set dataRng(2) = Range(.Cells(16, 1), .Cells(28, LCol))
Set dataRng(3) = Range(.Cells(31, 1), .Cells(43, LCol))
Set dataRng(4) = Range(.Cells(46, 1), .Cells(58, LCol))
Set dataRng(5) = Range(.Cells(61, 1), .Cells(73, LCol))
title(1) = Range("A1").Text
title(2) = Range("A16").Text
title(3) = Range("A31").Text
title(4) = Range("A46").Text
title(5) = Range("A61").Text
End With
For i = 1 To 5
ChartMaking dataRng(i), title(i)
Next i
End Sub
Private Sub ChartMaking(dataRng As Range, title As String)
ActiveWorkbook.Sheets("Charts").Activate
Charts.Add
With ActiveChart
.ChartType = xlXYScatterSmoothNoMarkers
.HasTitle = True
.ChartTitle.Text = title
.SetSourceData _
Source:=Sheets("Daily Total").dataRng, _
PlotBy:=xlColumns
.Location Where:=xlLocationAsObject, Name:="Charts"
.ChartWizard _
HasLegend = True, _
CategoryTitle:="Dates", _
ValueTitle:="Tickets"
End With
End Sub[/vba]
something wrong with my range declaration?