+ Reply to Thread
Results 1 to 3 of 3

Macro to fill in blanks with data from previous row

  1. #1
    Registered User
    Join Date
    04-11-2012
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2010
    Posts
    76

    Macro to fill in blanks with data from previous row

    Hello, I have a file with 8 columns, the first 5 of which will together be blank for some rows. I'm looking for a macro that takes the values from the preceding row and fills in the blanks. Occasionally there will be multiple consecutive rows of blanks that all need data populated from the most recent previous row with data in those 5 columns.

    My attachment has a before on the left and an after on the right, with the data to be copied in green and the copied data in yellow. Ultimately though I'm just looking for the data to be populated in place without color formatting; the attachment is just formatted as such to illustrate the problem and the desired solution.

    Thank you for any help you can provide!

    Matt
    Attached Files Attached Files

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

    Cool Hello, try this !


    According to your attachment a VBA demonstration for starters :

    PHP Code: 
    Sub Demo1()
              
    Dim Ra As Range
       With 
    [A1].CurrentRegion
         
    If Application.CountBlank(.Columns(1)) Then
         
    For Each Ra In .Columns(1).SpecialCells(4).Areas
                  Ra
    .Resize(, 5) = Ra(0).Resize(, 5).Value
         Next
         End 
    If
       
    End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  3. #3
    Registered User
    Join Date
    04-11-2012
    Location
    Nashville, TN
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Hello, try this !

    Works perfectly, thank you!

+ 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] VBA macro to fill in blanks with value from another column
    By BB1988 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-13-2020, 03:33 AM
  2. Fill in blanks with a value using a Macro
    By rz6657 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-10-2017, 10:14 PM
  3. Macro to fill in blanks with previous data
    By macronewbie9981 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2016, 01:56 PM
  4. Macro to fill blanks with listed data
    By jackubu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-08-2013, 02:48 AM
  5. [SOLVED] Trying to fill in Worksheet blanks by copying down previous cells
    By ppilot in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-23-2013, 02:06 PM
  6. Macro to fill in blanks with the data of the cell above
    By Fugazi_Dent in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-27-2013, 06:20 AM
  7. [SOLVED] Macro to fill in missing blanks with data in a column
    By robertguy in forum Excel General
    Replies: 6
    Last Post: 10-19-2012, 02:49 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