Hi,
I am new to VBA. I actually trying to learn on how vba work by trial and error.
In my worksheet, it involve with vba auto filter (support base and name) and vba advanced filter (month).
However, both auto filter and advanced filter cant run simultaneously on my data. What should i do in order for both of these filter. Is there any code they incorrect written
Attached is my worksheet which i working on.
Actually, i wanted to filter a range of people's birthday using month/ From example : if i input 11 in the entry cell, the filter result should be show the date fall on November.
In addition, i also want to filter their name and support location.
I am new to VBA. I actually trying to learn on how vba work by trial and error.
In my worksheet, it involve with vba auto filter (support base and name) and vba advanced filter (month).
However, both auto filter and advanced filter cant run simultaneously on my data. What should i do in order for both of these filter. Is there any code they incorrect written
Attached is my worksheet which i working on.
Actually, i wanted to filter a range of people's birthday using month/ From example : if i input 11 in the entry cell, the filter result should be show the date fall on November.
In addition, i also want to filter their name and support location.
Code:
Option Explicit
Sub TableFilt()
Dim ContName, ContSupport As String
Dim LastRow As Long
With Sheet1
LastRow = .Range("B99999").End(xlUp).Row
If LastRow < 4 Then LastRow = 4
If .Range("C3").Value = "Enter Name" Then ContName = Empty Else: ContName = .Range("C3").Value ' Name
If .Range("M3").Value = "Enter Support" Then ContSupport = Empty Else: ContSupport = .Range("M3").Value 'Support
.Range("B4:N" & LastRow).Select
Selection.AutoFilter
With .Range("B4:N" & LastRow)
If ContName <> Empty Then .AutoFilter Field:=2, Criteria1:="=*" & ContName & "*"
If ContSupport <> Empty Then .AutoFilter Field:=12, Criteria1:="=*" & ContSupport & "*"
End With
.Range("4:4").EntireRow.Hidden = False
End With
End Sub
Sub ClearFilt()
With Sheet1
.Range("A4").Value = True
.AutoFilterMode = False
.Range("C3").Value = "Enter Name"
.Range("H3").Value = "Enter Month"
.Range("M3").Value = "Enter Support"
.Range("A4").Value = False
End With
End Sub
Sub test()
Dim temp
With [h1:h2]
temp = .Value
.Cells(1).ClearContents
.Cells(2).Formula = "=month(h5)=$h$3"
End With
With Range("h4", Range("h" & Rows.Count).End(xlUp))
.AdvancedFilter 1, [h1:h2]
End With
[h1:h2].Value = temp
End Sub