+ Reply to Thread
Results 1 to 11 of 11

HELP: If cell is blank fill from above - but there is a catch

  1. #1
    Registered User
    Join Date
    12-10-2013
    Location
    Perth, Australia
    MS-Off Ver
    2010
    Posts
    4

    HELP: If cell is blank fill from above - but there is a catch

    Hey Guys,

    I have the following simple macro to fill the cells - if blank - with the data from the cell above. That works, however there is a catch.

    Code:
    ---------
    Sub FillColBlanks_Offset()
    'fill blank cells in column with value above

    Dim Area As Range, LastRow As Long
    On Error Resume Next
    LastRow = Cells.Find(What:="*", SearchOrder:=xlRows, _
    SearchDirection:=xlPrevious, _
    LookIn:=xlFormulas).Row
    For Each Area In ActiveCell.EntireColumn(1).Resize(LastRow). _
    SpecialCells(xlCellTypeBlanks).Areas
    Area.Value = Area(1).Offset(-1).Value
    Next
    End Sub
    ---------
    I want to be able to have the data in the cell selectable from a drop down list. If there is no selection made (cell blank), the cell will populate with the data from the last filled cell above, BUT when you go back and select something from the drop down list, it will automatically repopulate all the pre filled cells with updated data.

    eg. A1 selected from drop down list "DATA"

    all the cells below automatically fill with "DATA".

    however when I go to A17 and manually select the drop down list value of "VALUE" I need all the cells below (A18 - A?) to re-populate with "VALUE" whilst leaving the above cells A2 - A16 as "DATA"

    I admit I am NOT a VBA genius, so please be gentle with me.

    Thanks in advance.
    Last edited by jack_daniel; 12-10-2013 at 01:33 AM. Reason: Changed to meet rule #3

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: HELP: If cell is blank fill from above - but there is a catch

    Hi, jack_daniel,

    you would need to wrap your procedure with code-tags as requested by Forum Rule #3 instead of displaying in in red colour.

    For taking care of thr empty cells to be filled you might consider to use
    Please Login or Register  to view this content.
    The catch as you call it shall take care of any cells empty or already filled? Should that be started by an event like changing/entering data?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: HELP: If cell is blank fill from above - but there is a catch

    to fill blank cells from above from either selected or code-specified cell, try
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: HELP: If cell is blank fill from above - but there is a catch

    whoops, mustn't allow bugs, try
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-10-2013
    Location
    Perth, Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: HELP: If cell is blank fill from above - but there is a catch

    Kalak,

    Thanks - but that didn't seem to do anything

  6. #6
    Registered User
    Join Date
    12-10-2013
    Location
    Perth, Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: HELP: If cell is blank fill from above - but there is a catch

    Forgot to mention I need to start at row 8

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: HELP: If cell is blank fill from above - but there is a catch

    Hi, jack_daniel,

    please have a look at my signature in the first post on how to apply code tags.

    Forgot to mention I need to start at row 8
    From the opening post:
    whilst leaving the above cells A2 - A16 as "DATA"
    Like mentioned: I see two different codes necessary here.

    Ciao,
    Holger

  8. #8
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: HELP: If cell is blank fill from above - but there is a catch

    Earlier code started from active cell, thus required you to make a sheet selection first.
    You can manually select A8, if it's column A you're using, or to define the start cell with the code, replace the second line by
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    12-10-2013
    Location
    Perth, Australia
    MS-Off Ver
    2010
    Posts
    4

    Re: HELP: If cell is blank fill from above - but there is a catch

    Kalak,

    Sorry mate, still does nothing.

    Tried starting from the active cell, C8, selecting all the cells I want replaced, selecting the column, seems to do nothing - did I miss something?

    Thanks

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: HELP: If cell is blank fill from above - but there is a catch

    Hi, jack_daniel,

    Your opening post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger

  11. #11
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: HELP: If cell is blank fill from above - but there is a catch

    Holger,
    You're a tough taskmaster. Keep it up!


    Jack,
    I need to be elsewhere. Good luck!

+ 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. 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
  2. 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
  3. Formula to Automatically Fill Blank With Next fill cell's data?
    By VMoney in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-22-2013, 05:11 PM
  4. [SOLVED] Excel 2007 : Remove unwanted cell fill from blank cell
    By tradersteve in forum Excel General
    Replies: 4
    Last Post: 09-21-2010, 03:45 AM
  5. Repeat cell above (fill blank)
    By JanSurrey in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 02-04-2008, 11:23 AM

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