After reviewing the reference question (is the . in .Range necessary?) I tried removing the dot, adding a Worksheet("sheet1"), deleting the dot in front of the "Cells" object. If I run the code below "ActiveSheet" I clear up the "error 1004" however I never go to "Sheet1" and select the "k --> l" range I'm trying to define. Please advise.
ActiveSheet.Range(Cells(k, 1), Cells(l, 17)).Select
K and L hold the row numbers of the range I'm trying to select to feed into a pivot table. Everything is working until I get to the:
ThisWorkbook.Worksheets ("Sheet1").Range (Cells (k, 1), Cells (l, 17).Select
I get the error1004.
Public Sub Create_Report()
'Define range of report
ww_from = Application.InputBox _
(prompt:="From what is the workweek do you want to report?", Type:=1)
ww_to = Application.InputBox _
(prompt:="To what workweek do you want to report?", Type:=1)
'Find first row of data set locations
With ThisWorkbook.Worksheets("Sheet1").Range("C:C")
Set First = .Find(ww_from)
'Locate data set for report by row number
If Not First Is Nothing Then k = First.Row
'Find last row of data set locations
Set Last = .Find(ww_to + 1)
'Locate data set for report by row number
If Not Last Is Nothing Then
l = Last.Row - 1
Else
l = k
End If
ThisWorkbook.Worksheets("Sheet1").Range(Cells(k, 1), Cells(l, 17)).Select
End With