Link to home
Start Free TrialLog in
Avatar of PeterBaileyUk
PeterBaileyUk

asked on

clear spreadsheet to last row

I want to clear the spreadsheet but the code I have at present does not clear down properly leaving rows from before.

Set wks = Sheets("CWCodesToMatch")
      wks.Range("a1").CurrentRegion.ClearContents
      For iCols = 0 To qdf.OpenRecordset.Fields.Count - 1
            wks.Cells(1, iCols + 1).Value = qdf.OpenRecordset.Fields(iCols).Name
      Next

      wks.Range("A2").CopyFromRecordset qdf.OpenRecordset

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial