+ Reply to Thread
Results 1 to 4 of 4

Autofill code error

  1. #1
    Registered User
    Join Date
    10-18-2010
    Location
    NJ
    MS-Off Ver
    Excel 2007
    Posts
    73

    Autofill code error

    I have code that autofills B9:B if there is corresponding data in column A. It works fine when there is more than one row of data in the file. However it fails if column A only has one cell populated in a single row. Is there a way to fix my code so it will not fail in my scenario above?

    Range("B9").AutoFill Destination:=Range("B9:B" & Cells(Rows.Count, "A").End(xlUp).row)


    Thanks,
    Steve

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Autofill code error

    Hi Stevetothink,

    Sometimes, when the End(xlUp) just doesn't work, I revert to the old do loop:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    10-18-2010
    Location
    NJ
    MS-Off Ver
    Excel 2007
    Posts
    73

    Re: Autofill code error

    I'm not sure why but this doesn't work. Any other possible solutions? I have several autofills throughout my macro so I'm looking for a solution that will fix them all.

    Thanks,
    Steve

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Autofill code error

    Since, you're filling from the 9th row do we need to count from 9?

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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