+ Reply to Thread
Results 1 to 15 of 15

Making Autofill Dynamic

  1. #1
    Registered User
    Join Date
    05-16-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    54

    Making Autofill Dynamic

    Currently I have a piece of code which copies a Formula down and this code reads:

    Please Login or Register  to view this content.
    But I wish to make it dynamic as sometimes it won't be 6,000 lines. So I amended the code to as follows but sadly this doesen't work:

    Please Login or Register  to view this content.

    Anyone reckon they know what I'm doing wrong?

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Making Autofill Dynamic

    I would suggest NOT TESTED

    Please Login or Register  to view this content.
    Last edited by PCI; 11-11-2022 at 11:49 AM.
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,297

    Re: Making Autofill Dynamic

    Don't use AutoFill.

    Please Login or Register  to view this content.
    If there are any double quotes, double them up.

    The formula will auto adjust, just like AutoFill does.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Making Autofill Dynamic


    Do not use Selection but according to AutoFill VBA help just the source range …

  5. #5
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Making Autofill Dynamic

    Hi Steve1977.
    Let's imagine that from cell D3 downwards all those cells are empty.
    If so, then an expression like:

    Please Login or Register  to view this content.
    It will ALWAYS return the same row: 2.

    That's why you have to look for the last row of some column that is fully occupied: let's imagine that column is C.
    Then:

    Please Login or Register  to view this content.
    And this will return the last row and your attempt won't fail anymore.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,297

    Re: Making Autofill Dynamic

    @beyond Excel: good point. Focused too much on the fill range

  7. #7
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Making Autofill Dynamic

    It must be a contagious problem because we all think the same... At first! Ha ha ha

  8. #8
    Registered User
    Join Date
    05-16-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    54

    Re: Making Autofill Dynamic

    Quote Originally Posted by beyond Excel View Post
    Hi Steve1977.
    Let's imagine that from cell D3 downwards all those cells are empty.
    If so, then an expression like:

    Please Login or Register  to view this content.
    It will ALWAYS return the same row: 2.

    That's why you have to look for the last row of some column that is fully occupied: let's imagine that column is C.
    Then:

    Please Login or Register  to view this content.
    And this will return the last row and your attempt won't fail anymore.
    Would this be needed to be done in conjunction with AutoFill?

    I have added the code provided by TMS and it enters the Formula on the first two rows but nothing more. So it is working, kinda. But need it to enter in all lines where there is information if possible.

    Thank you for the help provided so far

    Auto Adjust.xlsm

  9. #9
    Registered User
    Join Date
    05-16-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    54

    Re: Making Autofill Dynamic

    Been having a further test around with this whereby it puts the Formula in cell C1 and I want to them copy this and paste it dynamically down, so my code now looks like this:

    Please Login or Register  to view this content.
    But it doesen't seem to copy the formula down :/

    Here's the updated example Auto Adjust2.xlsm

  10. #10
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Making Autofill Dynamic

    It seems obvious that you have not read anything suggested. So we will have to do everything.
    For example:

    PHP Code: 
    Sub AutoAdjustTest2()
    Range("C1:C" Cells(Rows.Count"A").End(xlUp).Row) = "= A1 + B1"
    End Sub 

  11. #11
    Registered User
    Join Date
    05-16-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    54

    Re: Making Autofill Dynamic

    Quote Originally Posted by beyond Excel View Post
    It seems obvious that you have not read anything suggested. So we will have to do everything.
    For example:

    PHP Code: 
    Sub AutoAdjustTest2()
    Range("C1:C" Cells(Rows.Count"A").End(xlUp).Row) = "= A1 + B1"
    End Sub 
    Not at all, everyone has been fantastic. You've unlocked my brain a little - see post 8. After this I decided to overhaul it rather than waiting for a reply and relying on people to do it all for me.
    But then ran it other problems
    Will take a look at what you suggest - once again, thank you for your response

  12. #12
    Registered User
    Join Date
    05-16-2019
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    54

    Re: Making Autofill Dynamic

    you beauty Beyond Excel! Thank you for the final piece of the jigsaw, it now works

    Please Login or Register  to view this content.

  13. #13
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,297

    Re: Making Autofill Dynamic

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  14. #14
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Making Autofill Dynamic

    Thanks Steve. Thank you TMS.

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,297

    Re: Making Autofill Dynamic

    @Steve: Thanks for the rep.
    @beyond Excel: You're welcome. Thanks for the rep.

    @Steve: the code that beyond Excel posted does not require any addition. Though really you should add .Formula

    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)

Similar Threads

  1. Making Dynamic Name Range more dynamic
    By dluhut in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-23-2019, 11:51 AM
  2. Autofill/Other Solution to making cell +8 each time
    By liamfrancis2013 in forum Excel General
    Replies: 1
    Last Post: 05-12-2016, 11:33 AM
  3. [SOLVED] Autofill/Other Solution to making cell +8 each time
    By liamfrancis2013 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-12-2016, 10:16 AM
  4. Autofill/Other Solution to making cell +8 each time
    By liamfrancis2013 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2016, 10:14 AM
  5. [SOLVED] Dynamic Autofill
    By ejoneslor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-11-2015, 12:06 PM
  6. Dynamic Autofill
    By Dan27 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2013, 10:30 AM
  7. Making an known amount of replicates in autofill
    By Reas in forum Excel General
    Replies: 3
    Last Post: 08-28-2012, 06:00 AM

Tags for this Thread

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