+ Reply to Thread
Results 1 to 8 of 8

Having trouble with formula and autofil

  1. #1
    Registered User
    Join Date
    09-19-2013
    Location
    VA, USA
    MS-Off Ver
    Excel 2007
    Posts
    28

    Having trouble with formula and autofil

    Hello all,

    I used formula and autofill it with number of rows of data I have. The problem is the formula and autofill are recorded in a macro and the number of rows are different everytime I run the macro. Example: the first time I run the macro with formula and doing the autofill for 100 rows of data I got at the time. It works ok. But then the next time I run the macro, given the # of rows of data are different, like 200 rows of data and when I run the macro with formula and autofill, it only filled up to 100 rows of data.

    I looked at the macro and I see the code below:

    Selection.AutoFill Destination:=Range("D2:D101")

    Is there a way to find the last row of data and autofill from D3 to last row of data only? Any other method besides finding the last row?


    Please help.

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Having trouble with formula and autofil

    Try

    Please Login or Register  to view this content.
    Adjust the "A" to whatever column that can determine the last used row of data.

  3. #3
    Registered User
    Join Date
    09-19-2013
    Location
    VA, USA
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Having trouble with formula and autofil

    Quote Originally Posted by Jonmo1 View Post
    Try

    Please Login or Register  to view this content.
    Adjust the "A" to whatever column that can determine the last used row of data.
    Jonmo1,

    Thank you very much for you help. Do I need to delcare lr first, as in what's its data type before using lr?

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Having trouble with formula and autofil

    You don't 'have to', but it's definately a good practice.

    I would declare it as a Long datatype

  5. #5
    Registered User
    Join Date
    09-19-2013
    Location
    VA, USA
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Having trouble with formula and autofil

    Quote Originally Posted by Jonmo1 View Post
    You don't 'have to', but it's definately a good practice.

    I would declare it as a Long datatype
    Thank you Jonmo1.

    Now that I got the last row, I want to insert data to the next blank row after the last row. What's the syntax to get the last row + 1? Please help.

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Having trouble with formula and autofil

    I would think
    lr+1

  7. #7
    Registered User
    Join Date
    09-19-2013
    Location
    VA, USA
    MS-Off Ver
    Excel 2007
    Posts
    28

    Re: Having trouble with formula and autofil

    Quote Originally Posted by Jonmo1 View Post
    I would think
    lr+1

    Thank you Jonmo1! I will try it. hmmm......lr+1 ...it's simple but I didn't even thought about it. Thank you

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Having trouble with formula and autofil

    You're welcome.

+ 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. [SOLVED] macro to autofil formula based on number of rows on adjacent column
    By kramtelbuab in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-13-2013, 08:28 PM
  2. [SOLVED] Autofil Solutions?
    By blincan in forum Excel General
    Replies: 3
    Last Post: 05-02-2012, 02:56 PM
  3. Autofil a formula
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-25-2009, 09:40 PM
  4. Autofil column with data from row?
    By skypilotpete in forum Excel General
    Replies: 8
    Last Post: 10-06-2008, 06:58 AM
  5. [SOLVED] Autofil a cell in the same row.
    By Mac5 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-30-2005, 08:05 PM

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