report excel filter [closed]

-1

I'm trying to make a report but I need a help for the worksheet to have to search by date and paste in another worksheet the data of that same date (example in the line that has today's date copy all of today and paste in the other worksheet). Home         spreadsheet link link

    
asked by anonymous 25.07.2018 / 23:22

1 answer

1

In UserForm1 use the code below:

Dim wsR As Worksheet
Dim wsD As Worksheet
Dim ul  As Long

If cdDataINI <> "" Or cdDataFIM <> "" Then
    Set wsR = ThisWorkbook.Sheets("RELATORIO")
    ul = wsR.Cells(wsR.Rows.Count, 1).End(xlUp).Row

    If wsR.Range("XFC1").Value = "" Then
        wsR.Range("F1").Copy wsR.Range("XFC1:XFD1")
    End If

    wsR.Range("A1:G" & ul + 1).ClearContents
    wsR.Range("XFC2").Value = ">=" & Format(cdDataINI, "mm/dd/yyyy")
    wsR.Range("XFD2").Value = "<=" & Format(cdDataFIM, "mm/dd/yyyy")

    Set wsD = ThisWorkbook.Sheets("dados")
    ul = wsD.Cells(wsD.Rows.Count, 1).End(xlUp).Row

    On Error Resume Next
    wsD.Range("A1:G" & ul).AdvancedFilter xlFilterCopy, wsR.Range("XFC1:XFD2"), wsR.Range("A1"), False

    MsgBox "Processo concluído - " & cdDataINI & " à " & cdDataFIM
End If
    
01.08.2018 / 02:54