PC Review


Reply
Thread Tools Rate Thread

1004 error only after 1st run

 
 
Tommy N
Guest
Posts: n/a
 
      30th Jul 2008
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error 1004 general odbc error excel 2003 vba =?Utf-8?B?TWVudG9z?= Microsoft Excel Programming 5 24th Jan 2011 02:56 PM
Error 1004 opening workbook 1004 WembleyBear Microsoft Excel Programming 2 30th Nov 2009 01:33 PM
Error when cell A1 is not active and xlInsideVertical border formatthrowing error 1004 sbitaxi@gmail.com Microsoft Excel Programming 7 7th Aug 2008 08:43 PM
RunTime Error 1004 when setting a series' error bars in Excel 2007 Steve Tummey Microsoft Excel Crashes 0 6th Feb 2008 01:37 PM
run-time error '1004': Application-defined or object-deifined error rich5665@gmail.com Microsoft Excel Programming 5 10th Aug 2005 09:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:13 PM.