Kentetsu
Well-known Member
- Joined
- Jan 22, 2004
- Messages
- 520
Hello,
I'm having some trouble determining what exactly the issue is here. For some reason, what is returned is only items related to the first date entered, rather than giving everything between the two dates.
Here is the code that performs the filter action:
Here is the complete code for this section of the program:
Any thoughts are appreciated...
I'm having some trouble determining what exactly the issue is here. For some reason, what is returned is only items related to the first date entered, rather than giving everything between the two dates.
Here is the code that performs the filter action:
Code:
.Range("A1:H80000").AutoFilter Field:=1, _
Criteria1:=">=" & Date1, _
Operator:=xlAnd, _
Criteria2:="<=" & Date2
Here is the complete code for this section of the program:
Code:
Option Explicit
Sub GrabData()
Dim Target1 As String
Dim Date1 As Date
Dim Date2 As Date
Dim Div As String
Target1 = "J:\BBS Tracking\BBSLog.xlsm"
Date1 = Sheets("BBS Reporting").Range("D22") '.Value
Date2 = Sheets("BBS Reporting").Range("D23") '.Value
Div = Sheets("BBS Reporting").Range("D4").Value
Workbooks.Open Target1, ReadOnly:=True
With Worksheets("Log")
.Activate
.Unprotect Password:="*******"
.Range("A1:H80000").AutoFilter Field:=1, _
Criteria1:=">=" & Date1, _
Operator:=xlAnd, _
Criteria2:="<=" & Date2
.Range("A1:H80000").AutoFilter Field:=2, _
Criteria1:=Div
Worksheets.Add.Name = "Summary"
Sheets("Log").Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row).SpecialCells(xlCellTypeVisible).Copy
Sheets("Summary").Activate
ActiveSheet.Paste
Application.DisplayAlerts = False
Sheets("Log").Delete
Sheets("Sheet2").Delete
Sheets("Sheet3").Delete
Application.DisplayAlerts = True
End With
With Sheets("Summary")
.Columns("A:H").ColumnWidth = 14
.Range("A1:H500").Select
With Selection
.HorizontalAlignment = xlCenter
End With
End With
Any thoughts are appreciated...