Hi Dave!
Some mistake in copy-paste, I suppose.
I see a "With xLWB" at the top of the code and no one "End With" at the bottom.
Take care to compile your code after each editing and always keep at the top of the module those lines:
Code:
Option Compare Database
Option Explicit
Furthermore, if you don't mind to export all returned records, of each RemQty value, to Excel in one step as a solid block of data, give a try to the code bellow:
Code:
Set rs = db.OpenRecordset("SELECT tblRemovals.RemNo, tblRemovals.Client, tblRemovals.Add1, tblRemovals.Add2, tblRemovals.Town, tblRemovals.Postcode, " _
& "tblRemovals.Tel, tblRemovals.Mobile, tblRemovals.LiftMake, tblRemovals.LiftModel FROM tblRemovals " _
& "WHERE Engineer = '" & mDriver & "' And RemovalDate = #" & RemDate & "# And (RemNo > 0) AND (RemNo <=" & RemQty & ")", dbOpenSnapshot)
'Export all records to worksheet in one step.
xLWB.Worksheets(1).Cells(14, 1).CopyFromRecordset rs
This approach eliminates the necessity of a loop.
Good luck!