+ Reply to Thread
Results 1 to 2 of 2

Macro to populate a range of blank cells from a base cell

  1. #1
    Registered User
    Join Date
    01-26-2015
    Location
    Kuala Lumpur
    MS-Off Ver
    2013
    Posts
    1

    Macro to populate a range of blank cells from a base cell

    Hi,
    I have a requirement to populate a range of cell from the value of a base cell.
    Scenario.
    1. Base cell = B1.
    2. There is another value in cell B7 and cells B2:B6 are blank.
    3. I want to copy the value of B1 to B2:B6.
    4. There is another value in cell B10 and cell B8:B9 are blank.
    5. I want to copy the value of B7 to B8:B9.

    Based on the scenario above, I want a macro which copy the values to a dynamic range of cells.

    From recording a macro, I get the following code:-
    --------------------------------------------------------------------------------------------------------------------------------------------
    Sub Flowdown()
    '
    ' Flowdown Macro
    '
    Selection.Copy
    ActiveCell.Offset(1, 0).Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    ActiveCell.Range("A1:A6").Select
    ActiveSheet.Paste
    ActiveCell.Offset(-1, 0).Range("A1").Select
    Selection.End(xlDown).Select
    End Sub
    --------------------------------------------------------------------------------------------------------------------------------------------

    The problem with the code is the red line above. The selection of cells to paste is not dynamic. How can I change the line to make it dynamic based on the number of blank cells?

    Thanks in advance.
    Eddie Lee

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Macro to populate a range of blank cells from a base cell

    You can do this without a macro, or:
    Please Login or Register  to view this content.

+ 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] How to populate blank cells with sequence until nonblank cell is encountered?
    By Jasonhouse in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-23-2014, 08:47 AM
  2. Replies: 2
    Last Post: 11-22-2013, 01:07 PM
  3. Populate Blank Cells with a Macro
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-16-2013, 08:36 AM
  4. Variable range SUM , base range on other column blank cells?
    By stevnb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-20-2012, 10:55 AM
  5. Replies: 8
    Last Post: 03-03-2011, 03:28 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