Darren Smith
Well-known Member
- Joined
- Nov 23, 2020
- Messages
- 631
- Office Version
- 2019
- Platform
- Windows
This has a CDate function which needs to be a Month name is this possible?
VBA Code:
Private Sub Filter_Jobs_By_Months_Click()
Dim ws As Worksheet
Dim qt As QueryTable
Dim Mounths_List() As String
Dim IngStart As Long
Dim IngEnd As Long
Application.ScreenUpdating = False
Set ws = ThisWorkbook.Worksheets("TGS JOB RECORD")
For Each ws In ActiveWorkbook.Worksheets
For Each qt In ws.QueryTables
qt.Refresh
Next qt
IngStart = VBA.CDate(ws).Me.StartMonth
IngEnd = VBA.CDate(ws).Me.StartMonth
Application.ScreenUpdating = True
If IngStart > IngEnd Then
MsgBox "The Start Date Can Not be Bigger Then The End Date.", vbCritical, ""
Exit Sub
End If
ws.Range("A:A").AutoFilter Field:=11, _
Criteria1:=">=" & IngStart, Operator:=xlAnd, Criteria2:="<=" & IngEnd
With ws
.Range("K2").Value = Application.WorksheetFunction.Subtotal(2, .Range("A2:A" & .Rows(.Rows.Count).End(xlUp).Row))
End With
Application.ScreenUpdating = True
End Sub