+ Reply to Thread
Results 1 to 4 of 4

Macro for filling fields (copy) within Column

  1. #1
    Registered User
    Join Date
    11-12-2019
    Location
    NL
    MS-Off Ver
    Office365
    Posts
    2

    Macro for filling fields (copy) within Column

    Hello everyone,

    As new as one can be to VBA <= well that's me. Looking for a push in the right direction here..

    Imagine you have a unique value in column D2, which you want to copy to (D3:D4). You select D2 and double-click the pointer, select 'Copy Cells' in the option menu and I'm done.
    What if I have to repeat this action for the entire column D.
    So all the empty rows should be filled with a copy from the first unique value that's filled above.

    Opening the VBA Module1(Code) and looking at what excel is recording, only shows each separate action:
    ----
    Sub FORMULA()
    '
    ' FORMULA Macro

    Range("D2").Select
    Selection.AutoFill Destination:=Range("D2:D4"), Type:=xlFillCopy
    Range("D2:D4").Select

    Range("D5").Select
    Selection.AutoFill Destination:=Range("D5:D7"), Type:=xlFillCopy
    Range("D5:D7").Select

    Range("D8").Select
    Selection.AutoFill Destination:=Range("D8:D13"), Type:=xlFillCopy
    Range("D8:D13").Select
    End Sub
    ----

    How can we create a loop to auto-FillCopy the empty cells with the unique values - within column D?
    (Please find image attached)

    Thanks in advance!
    Attached Images Attached Images

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Macro for filling fields (copy) within Column

    You don't need a loop.

    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    11-12-2019
    Location
    NL
    MS-Off Ver
    Office365
    Posts
    2

    Re: Macro for filling fields (copy) within Column

    Many thanks Olly, works like a charm!

    Much appreciated!!

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Macro for filling fields (copy) within Column

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

    Also, as a relatively new member of the forum, 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.

+ 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. Filling in blank fields with data from above
    By ollyr in forum Excel General
    Replies: 4
    Last Post: 02-19-2017, 08:43 AM
  2. Macro to copy/paste fields no faster than 10 fields per second
    By gdamato in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-02-2016, 04:38 PM
  3. Question about filling only certain fields
    By Cutiesusiederkins in forum Excel General
    Replies: 7
    Last Post: 07-23-2012, 09:16 AM
  4. The macro for filling the text in blank column
    By ronlau123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-12-2011, 05:13 PM
  5. fields filling issue
    By adeelkhan007 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-01-2011, 02:56 AM
  6. Auto-Filling Fields
    By MFO_Jester in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-13-2010, 09:46 PM
  7. Filling fields when sending a workbook.
    By Flima in forum Excel General
    Replies: 0
    Last Post: 02-15-2006, 04:30 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