Hello everyone,
I am writing a macro to plot a graph based on the date entered into the InputBox. When the date is entered it filters the data based on the date, then I want to select all the data in for that particular date in rows c and d to graph.
I am getting errors in the bold below while I am trying to figure this out. The current error is "Run-time error 91 on line myDate = Range(Selection, Selection.End(xlDown)).Select . Object variable or With block variable not set". I searched the error online without any luck of fixing the error. Can someone please help me with this?
Dim SDate As String
Dim myDate As Range
Sheet5.Select
SDate = InputBox(prompt:="Please enter date MM/DD/YYYY", Title:="Plot Graph by Date")
'Terminates here if empty
If SDate = Empty Then Exit Sub
'Continues here if not empty...
ActiveSheet.Range("$A$1:$L$99999").AutoFilter Field:=2, Operator:= _
xlFilterValues, Criteria2:=Array(2, SDate)
'Add new sheet at end and rename
Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Select
Sheets(Sheets.Count).Name = InputBox("Please enter the new sheet name i.e. AMT Depth MM DD")
'Add line chart from selected data
ActiveSheet.Shapes.AddChart.Select
Sheet5.Select
Range("C2:D3").Select
Range(Selection, Selection.End(xlDown)).Select
myDate = Range(Selection, Selection.End(xlDown)).Select
Set myDate = myDate.Select
ActiveChart.SetSourceData Source:=Sheet5.Range(myDate), PlotBy:=xlColumns
ActiveChart.ChartType = xlLine
Jordan
Bookmarks