+ Reply to Thread
Results 1 to 2 of 2

Macro for Autofill removes header info when there is no data to autofill

  1. #1
    Registered User
    Join Date
    07-20-2011
    Location
    Reading
    MS-Off Ver
    Excel 2007
    Posts
    1

    Macro for Autofill removes header info when there is no data to autofill

    Hi
    I have seperate worksheets. Data is populated on each sheet and then macro is run to autofill the formula in columns depending on data populated in Column A

    However I am now getting to a situation where on one of the sheets, there is no data.

    When the macro is run, then the xlup part I assume is now overwriting the header (because there is no data in Column A) this in turn messes up pivots tables and so on.

    So I have my header on row 1

    What I need to is to modify my macro so that if no data exists in cell A2, then it will move on to the next line. The current code is:

    Sheets("xxxx").Select
    Range("H2:L2").AutoFill Destination:=Range("H2:L" & Cells(Rows.Count, "A").End(xlUp).Row) - so this works spot on when there is data, however when there is no data the the formula overwrites the header info in cells H1 to L1

    I have tried to modify the code but no end of errors. I have searched no end on this forum but cannot find the answer.. I guess it needs something like "If A2 is blank then goto.....else"

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro for Autofill removes header info when there is no data to autofill

    Does this help any?

    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