report filter excel

Asked

Viewed 108 times

-1

I am trying to make a report but I need a help the spreadsheet has to search by date and paste in another spreadsheet the data of that same date (example on the line that is dated today copy everything of today and paste in the other spreadsheet).
spreadsheet link https://drive.google.com/open?id=17lExk1BkDxXVctEXj7hxjl2clMOAx2u4

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.