Barbora
05-21-2015, 08:00 AM
Hi all,
would you be able to advise how to apply two conditions in filter please?
The thing is, that I need to filter only dates befor actual month and year in the same time. For example, today is 21.05.2015 so I need only entries related at latest to 31.4.2015. It's not able for me to change format to date and do easy function with dates, because this is output from internal system and format couldn't be change.
Sub FilterMonths()
Set original009 = Sheets("Original Input")
Dim datum As Date
Dim z As Integer
datum = Date
actualMonth = DatePart("m", datum)
actualYear = DatePart("y", datum)
z = 14
original009.Range("J13") = "Month2"
original009.Range("K13") = "Year2"
Do While (original009.Cells(z, 9) <> "")
original009.Cells(z, 10) = Mid(original009.Cells(z, 9), 4, 2)
original009.Cells(z, 11) = Mid(original009.Cells(z, 9), 7, 4)
z = z + 1
Loop
original009.Range("C13:K10000").AutoFilter Field:=8, Criteria1:="<>" & actualMonth, Field:=9, Criteria2:="<>" & actualYear
End Sub
And the input looks like this:
13462
Thank you a lot!
would you be able to advise how to apply two conditions in filter please?
The thing is, that I need to filter only dates befor actual month and year in the same time. For example, today is 21.05.2015 so I need only entries related at latest to 31.4.2015. It's not able for me to change format to date and do easy function with dates, because this is output from internal system and format couldn't be change.
Sub FilterMonths()
Set original009 = Sheets("Original Input")
Dim datum As Date
Dim z As Integer
datum = Date
actualMonth = DatePart("m", datum)
actualYear = DatePart("y", datum)
z = 14
original009.Range("J13") = "Month2"
original009.Range("K13") = "Year2"
Do While (original009.Cells(z, 9) <> "")
original009.Cells(z, 10) = Mid(original009.Cells(z, 9), 4, 2)
original009.Cells(z, 11) = Mid(original009.Cells(z, 9), 7, 4)
z = z + 1
Loop
original009.Range("C13:K10000").AutoFilter Field:=8, Criteria1:="<>" & actualMonth, Field:=9, Criteria2:="<>" & actualYear
End Sub
And the input looks like this:
13462
Thank you a lot!