+ Reply to Thread
Results 1 to 5 of 5

Macro to filldown rows

  1. #1
    Registered User
    Join Date
    03-24-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Question Macro to filldown rows

    Hi,

    I am hoping someone can help me build this macro. I am trying to filldown rows with information on the previous row till a change happens and then fill down rows with the new value till a change and fill down .. and so on.. till the last row

    To make it simpler, here's how my spreadsheet looks -
    NUMBER DATE
    1 3/4/2010
    3/5/2010
    3/5/2010
    3/5/2010
    2 3/4/2010
    3/5/2010
    3/5/2010
    3/5/2010
    3/5/2010
    4 2/25/2010
    3/5/2010
    3/5/2010
    So, I want to fill (in Column 1), rows 2-4 with value 1; row 6-9 with value 2, row 11-12 with value 4. so on.

    Thanks!
    Last edited by divkar; 03-25-2010 at 11:19 AM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Macro to filldown rows

    Please Login or Register  to view this content.

    Open up the VBA editor by hitting ALT F11

    Insert a new module by hitting Insert - Module

    Paste the macro into the empty sheet

    Hit ALT F11 to get back to the worksheet.

    Run the macro by going to tools-macro in Excel 2003 or the view ribbon in Excel 2007 selecting the area in column 1 before running.
    Martin

  3. #3
    Registered User
    Join Date
    03-24-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Macro to filldown rows

    Thank you so much! That worked. If I wanted to include the selection in the macro without having to manually select the column, should I just mention the Column in the 3rd line ?
    ie.

    Sub FillIn()
    Dim Cell As Range
    For Each Cell In Column A
    If Cell = "" Then Cell = Cell.Offset(-1, 0)
    Next Cell
    End Sub

  4. #4
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: Macro to filldown rows

    You can select the column progrmatically, without having to do it manually:-

    Please Login or Register  to view this content.
    (not tested)

    hth
    Ajay

  5. #5
    Registered User
    Join Date
    03-24-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Thumbs up Re: Macro to filldown rows

    Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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