1004 error only after 1st run

T

Tommy N

Dim ws As Excel.Worksheet
Dim z As Excel.Range

Dim rs As New ADODB.Recordset
Dim rc As Integer

rs.Open "ModifiedData", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic, adCmdTable
rc = rs.RecordCount

rs.Close
Set rs = Nothing
Set C = Nothing

Set ws = wb.Worksheets("Pivot Data")
Set z = ws.Range("A2:R2")
z.Select
Selection.AutoFill Destination:=Range(Cells(2, 1), Cells(rc + 1, 18)),
Type:=xlFillDefault
Range("A1").Select

I am getting a 1004 error on this code on my second a subsequent attempts to
run this code. It runs the first time fine. Any ideas on what is wrong with
this code. the line of code that it is stopping on is the AutoFill line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top