DBaker7777
Board Regular
- Joined
- Feb 3, 2009
- Messages
- 53
- Office Version
- 365
- 2016
I have this code so far, but this only copies and adds the data to new rows for the range. I want to insert the data from the Data Entry sheet from the user defined date range to a table on the Report sheet, but have the table clear before inserting the new data.
VBA Code:
Sub Reporting()
Dim lastrow as Long, i as long, erow as Long
Dim sheetdate as Date, startdate As Date, enddate as Date
lastrow = Worksheets("DataEntry").usedrange.rows.count
startdate = Inputbox ("Enter start date as mm-dd-yyyy","Enter start date")
enddate = Inputbox ("Enter the end date as mm-dd-yyyy","Enter end date")
For i = 2 To lastrow
sheetdate = Cells(i, 1)
If sheetdate >= startdate and sheetdate <= enddate Then
erow = Worksheets("Report").UsedRange.Rows.Count + 1
Range (Cells(i,1), Cells(i, 5)).Copy Destination:=Sheets("Report").cells(erow, 1)
End If
Next I
End Sub