+ Reply to Thread
Results 1 to 11 of 11

AutoFill with dynamic destination

  1. #1
    Registered User
    Join Date
    11-21-2017
    Location
    Tel aviv, Israel
    MS-Off Ver
    standard 2013
    Posts
    8

    Question AutoFill with dynamic destination

    Hi,

    I'm really stuck, tried various things, and none worked.

    I have a data table that I add data to it constantly and automaticly with a diffrent Macro

    the data I add is on columns A to P, and on columns Q to V there are formulas.

    I need the Macro to AutoFill the formulas in columns Q to V to the rows added..

    Among many things, I tried this:

    dim lastrow as Long

    lastrow = Range("A" & Cells.Rows.Count).End(xlUp).Row

    Range("Q" & Cells.Rows.Count).End(xlUp).Select
    Selection.AutoFill destination = Range("Q" & lastrow)


    but it doesnt work..
    Any ideas? I really need this to work...

    Thank you!

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: AutoFill with dynamic destination

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-21-2017
    Location
    Tel aviv, Israel
    MS-Off Ver
    standard 2013
    Posts
    8

    Re: AutoFill with dynamic destination

    Thank you for the fast reply,

    But I'm affraid that didn't work either...
    Last edited by Yonch; 11-21-2017 at 12:12 PM.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: AutoFill with dynamic destination

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and click "manage attachments" to open the upload window.


    To add a file to a post

  5. #5
    Registered User
    Join Date
    11-21-2017
    Location
    Tel aviv, Israel
    MS-Off Ver
    standard 2013
    Posts
    8
    Can u explain some more, how to ise attachments? I'm not farmiliar with that option

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: AutoFill with dynamic destination

    You could also click the link to a youtube video that shows how to do it.

  7. #7
    Registered User
    Join Date
    11-21-2017
    Location
    Tel aviv, Israel
    MS-Off Ver
    standard 2013
    Posts
    8

    Re: AutoFill with dynamic destination

    Ok, A small breakthrough.

    I have better understandment of what I need.

    And I'm attachimg an example sheet I made for others to work with (I didn't add the original one because it is very complex and messy and is in Hebrew)

    this code works fine:
    Sub exampleofwhatineed()

    Dim lastrow As Long
    lastrow = Range("C" & Cells.Rows.Count).End(xlUp).Row
    Dim LastRowOfDest As Long
    LastRowOfDest = Range("A" & Cells.Rows.Count).End(xlUp).Row


    Range("C" & lastrow).Select
    Selection.AutoFill Destination:=Range("C2:C" & LastRowOfDest)


    End Sub
    but, it only works if the destnation range is as written above, given that "C2" is the selected range which I wish to AutoFill.
    To My Table I'm always adding new rows so each time the selected range will be on a different row (Range("C" & lastrow).Select)

    So, I'm trying to find a way to set not only the selected range but also the destination range accroding to the value of lastrow.

    I tried these, non worked:

    Range("C" & lastrow).Select
    Selection.AutoFill Destination:=Range("C" & lastrow & "C" & LastRowOfDest)

    Range("C" & lastrow).Select
    Selection.AutoFill Destination:=Range("C" & lastrow & "C" & LastRowOfDest)

    Range("C" & lastrow).Select
    Selection.AutoFill Destination:=Range("C" & lastrow, "C" & LastRowOfDest)

    Range("C" & lastrow).Select
    Selection.AutoFill Destination:=Range("C" & lastrow & LastRowOfDest)

    Range("C" & lastrow).Select
    Selection.AutoFill Destination:=Range("C" & lastrow, LastRowOfDest)

    ext..



    So I fell like I'm close but not ther yet...

    Please help! Thamks a lot
    Attached Files Attached Files

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: AutoFill with dynamic destination

    You can edit your posts and add code tags to the VBA code.

    See Picture

    AA CodeTags.jpg

  9. #9
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: AutoFill with dynamic destination

    You could be stuck on AutoFill, not really required.

    Please Login or Register  to view this content.
    BTW, if you wanted to do this without the formulas on the sheet:

    Please Login or Register  to view this content.
    Last edited by davesexcel; 11-22-2017 at 09:07 AM.

  10. #10
    Registered User
    Join Date
    11-21-2017
    Location
    Tel aviv, Israel
    MS-Off Ver
    standard 2013
    Posts
    8
    Quote Originally Posted by davesexcel View Post
    You can edit your posts and add code tags to the VBA code.

    See Picture

    Attachment 548855
    Thanks, I will from now on.. Do you have some suggestions about how to write the autofill destination correctly?

  11. #11
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: AutoFill with dynamic destination

    You mean other than Post#9?

+ 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] Dynamic AutoFill Destination Range
    By cesrua in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-18-2016, 03:33 PM
  2. Copy from static destination & paste to dynamic destination
    By Marbleking in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-31-2015, 09:31 AM
  3. Selection AutoFill Destination
    By h.noor in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-09-2015, 01:39 AM
  4. [SOLVED] Autofill Destination Range
    By ERaasio in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-14-2014, 03:02 PM
  5. [SOLVED] AutoFill Destination
    By batchy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-06-2014, 12:22 PM
  6. Autofill in VBA with a dynamic "Destination" range
    By ConneXionLost in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-04-2011, 04:55 PM
  7. autofill to variable destination
    By katmison in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-30-2009, 06:57 PM

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