+ Reply to Thread
Results 1 to 5 of 5

VBA code to fill blank cells ranges

  1. #1
    Registered User
    Join Date
    02-12-2010
    Location
    Porto Alegre, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    14

    Question VBA code to fill blank cells ranges

    Hi there,

    I'm facing difficulties to make a code that allow me to complete my databases in a smart way. This one should be easy...

    According to the attached image, I need a code that fill the column A from the bottom to the top completing the blank cells with the last value found before the blank cell itself. For example: cells 8 and 7 should be filled with "Ford" and 5, 4 and 3 should be filled with "Honda".

    img1.JPG

    Can anyone help me?

    Thank you so much!

  2. #2
    Forum Contributor tax112's Avatar
    Join Date
    02-28-2013
    Location
    Thailand
    MS-Off Ver
    Excel 2016 | 2019
    Posts
    442

    Re: VBA code to fill blank cells ranges

    Quote Originally Posted by Nienaber View Post
    Hi there,

    I'm facing difficulties to make a code that allow me to complete my databases in a smart way. This one should be easy...

    According to the attached image, I need a code that fill the column A from the bottom to the top completing the blank cells with the last value found before the blank cell itself. For example: cells 8 and 7 should be filled with "Ford" and 5, 4 and 3 should be filled with "Honda".

    Attachment 422925

    Can anyone help me?

    Thank you so much!
    Select A2: A8
    Run the following code:
    Please Login or Register  to view this content.

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,691

    Re: VBA code to fill blank cells ranges

    Try this:

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,228

    Re: VBA code to fill blank cells ranges

    I agree with Alan's code but I like to use "Cell" instead of "Range". I'd write it like:

    Please Login or Register  to view this content.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Registered User
    Join Date
    02-12-2010
    Location
    Porto Alegre, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: VBA code to fill blank cells ranges

    Quote Originally Posted by MarvinP View Post
    I agree with Alan's code but I like to use "Cell" instead of "Range". I'd write it like:

    Please Login or Register  to view this content.
    That worked perfectely! Thanks a lot!

+ 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] Code to exit and not call module if certain ranges are blank
    By bdouglas1011 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-07-2014, 09:00 PM
  2. [SOLVED] Macro to fill blank cells in column A based on non-blank cells
    By ktalamantez in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-28-2014, 02:47 PM
  3. VBA code to fill blank cells with variable formula
    By Khen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-08-2014, 08:24 AM
  4. Fill blank cells with data directly above that blank cell
    By gibson2503 in forum Excel General
    Replies: 3
    Last Post: 06-05-2013, 10:07 AM
  5. MIN of Summed ranges, excluding any ranges with blank cells)
    By Melvinrobb in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-08-2013, 12:02 PM
  6. How to color-fill blank cells, then once data is entered cell is no-fill
    By hatemail13 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-28-2013, 07:57 PM
  7. Replies: 0
    Last Post: 04-07-2009, 04:42 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