I am trying to use a filter function with data from a seconf workbook. I have the following formula, but I am getting expected end of statement in the first Range and I don't know why:
VBA Code:
sub tenplate()
Dim gen As String, template As String, lr As Long, data As String, name As String, i As Long, wb1 As Workbook, wb2 As Workbook, ws1 As Worksheet, ws2 As Worksheet
gen = ThisWorkbook.name
data = archivo
Set wb1 = Workbooks(gen)
Set wb2 = Workbooks(data)
Set ws1 = Sheets("Trabajo")
Set ws2 = Sheets("Rpt")
For i = 1 To Worksheets.Count
Workbooks(gen).Activate
Worksheets(i).Activate
name = ActiveSheet.name
wb1.ws1.Range("A6").Formula2 = "=filter(wb2.ws2.Range("A6:P65536"),wb2.ws2.Range("C6:C65536")=wb1.ws1.Range("D1"),"""")"
end sub