I want to export all queries in my database with the beginning "WWEI", which have records, into one Excel worksheet and list them under each other.
strFullPath = "C:\Users\test.xlsx"
Set wb = xl.Workbooks.Add
Set wb = xl.Workbooks.Open(strFullPath)   
Set ws = wb.Worksheets(1)      
Set r = ws.Range("a1")         
r = "Possible Mistakes"
Set r = r.Offset(2, 1)
For Each qdf In CurrentDb.QueryDefs
    If Mid(qdf.Name, 1, 4) = "WWEI" Then
        querybezeichnung = qdf.Name
        If DCount("*", querybezeichnung) > 0 Then
            Set rs = CurrentDb.OpenRecordset(querybezeichnung)
            With rs
                For i = 1 To .Fields.Count
                    r.Cells(1, i) = .Fields(i - 1).Name
                    r.Cells(1, i).Font.Bold = True
                    'r.Cells(1, i).AutoFilter
                Next i
            End With
            Set r = r.Offset(1, 0)
            r.CopyFromRecordset rs
            rs.Close
            Set r = r.End(xlDown).Offset(2, 0)
        End If
    End If
Next qdf
I have a runtime error "1004" on line:
Set r = r.End(xlDown).Offset(2, 0)
 
     
     
    