jeudi 26 juillet 2018

If statement when cell is not empty

Could you please help me clear this code?

I'm trying to filter out certain dates and in case that no cells are visible not to action the code.

For some reason i cannot get to IF working properly.

 Dim EndDate1, StartDate1 As Long
 Dim todayDate1 As Long


 Sheets("Macro").Select
 todayDate1 = Sheets("Macro").Cells(2, 2)

 Sheets("FTC").Select
 StartDate1 = DateSerial(Year(todayDate1), Month(todayDate1), Day(todayDate1) + 14) 
 EndDate1 = DateSerial(Year(todayDate1), Month(todayDate1), Day(todayDate1) + 21)   

 ActiveSheet.Range("$A$1:$AP$1000").AutoFilter Field:=24, Criteria1:=">=" & StartDate1, Operator:=xlAnd, Criteria2:="<" & EndDate1


    Range("A2:A1000").Select
    Selection.SpecialCells(xlCellTypeVisible).Select

    If Selection.SpecialCells(xlCellTypeVisible).Count > 1 Then
            MsgBox "Nope"
            End If     
            MsgBox "Yay"

Aucun commentaire:

Enregistrer un commentaire