+ Reply to Thread
Results 1 to 3 of 3

vba autofill creates run-time error 1004 when only one line exists

  1. #1
    Registered User
    Join Date
    04-22-2014
    Location
    Pratt, KS
    MS-Off Ver
    Excel 2003
    Posts
    7

    vba autofill creates run-time error 1004 when only one line exists

    I'm using this vba code to copy/paste a formula down to the range of cells equivalent to column A. It works great with multiple lines, but when only one line exists I get a Run-time error 1004: Auto fill method of Range Class Failed message. What do I need to add (or correct) so it works on one line or multiple lines? I really appreciate your help!


    Range("B2").Select
    ActiveCell.FormulaR1C1 = "=+RC[2]&""CH"""
    Selection.AutoFill Destination:=Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row)
    Range(Selection, Selection.End(xlDown)).Select

  2. #2
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,032

    Re: vba autofill creates run-time error 1004 when only one line exists

    Try

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-22-2014
    Location
    Pratt, KS
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: vba autofill creates run-time error 1004 when only one line exists

    Yes, perfect! Thank you for the quick response!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. PasteSpecial causing RunTime error 1004 & autofill doesn't stop at last line
    By Sc0tt1e in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-24-2014, 09:18 AM
  2. [SOLVED] Run-time error '1004' when executing Exit Sub command line
    By Henk Stander in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 08-29-2014, 02:50 AM
  3. [SOLVED] Run time error 1004 - why is the last line of this code causing this?
    By SweetSorcery in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 07-14-2014, 06:57 AM
  4. Run-time error '1004' - Autofill method of range class failed
    By zhout2 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-26-2013, 01:47 PM
  5. Run-Time Error '1004' AutoFill method of Range class Failed
    By RS944 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-15-2013, 11:37 AM
  6. Run time Error 1004 in 5th line of IF..THEN..ELSE
    By go-fish in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-19-2010, 05:17 AM
  7. Run time error '1004' Autofill method of Range class failed
    By lanie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2009, 08:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1