skull_eagle
Board Regular
- Joined
- Mar 25, 2011
- Messages
- 89
Hi,
I'm trying to filter a column by date.
Less than cell value to greater than cell value. Cell value is in Date format.
Instead of using the date in the filter it is using the numeric value of the date eg. 32300
I don't understand why the below won't appear as 06/06/1988 instead of 32300
Criteria1:="<" & Format([DateVal], "dd/mm/yyyy")
Any help would be greatly appreciated.
I'm trying to filter a column by date.
Less than cell value to greater than cell value. Cell value is in Date format.
Instead of using the date in the filter it is using the numeric value of the date eg. 32300
I don't understand why the below won't appear as 06/06/1988 instead of 32300
Criteria1:="<" & Format([DateVal], "dd/mm/yyyy")
Any help would be greatly appreciated.
VBA Code:
Public WithEvents mLabelGroup2 As MSForms.ComboBox
Private Sub mLabelGroup2_Click()
''-- A live filter based on the value of the Combo boxes on the search form
Dim ControlName2, ColNum2
Dim Rowz As Long
Dim wsRD As Worksheet
Dim DateVal As Date
On Error Resume Next
Set wsRD = Worksheets("RawData")
Set wsRD = ActiveSheet
ControlName2 = mLabelGroup2.Name
ColNum2 = Replace(ControlName2, "CM_", "")
i = Search_Form.Controls("CM_" & ColNum2).Value
If Search_Form.Controls("CM_" & ColNum2).Value = "" Then
ActiveSheet.ListObjects("Table_RawData").Range.AutoFilter Field:=ColNum2
Else
ActiveSheet.ListObjects("Table_RawData").Range.AutoFilter Field:=ColNum2, _
Criteria1:=i
End If
DateVal = Worksheets("Admin").Range("P6")
If ColNum2 = 6 Then
If Search_Form.Controls("CM_" & ColNum2) = "< 35" Then
ActiveSheet.ListObjects("Table_RawData").Range.AutoFilter Field:=6, _
Criteria1:="<" & Format([DateVal], "dd/mm/yyyy")
ElseIf Search_Form.Controls("CM_" & ColNum2) = "> 35" Then
ActiveSheet.ListObjects("Table_RawData").Range.AutoFilter Field:=6, _
Criteria1:=">" & Format([DateVal], "dd/mm/yyyy")
Else
ActiveSheet.ListObjects("Table_RawData").Range.AutoFilter Field:=6
End If
End If