+ Reply to Thread
Results 1 to 3 of 3

VBA or Macro to auto fill a selected range

  1. #1
    Registered User
    Join Date
    04-20-2004
    Posts
    17

    VBA or Macro to auto fill a selected range

    Hello everyone,

    Here is my problem. I have a spreadsheet with four columns, which are variables nested within each other. What I am currently doing is going through a range, finding the blank cells, filling all the blanks with the value of the non-blank cell above it, and filling these blanks until I reach a non-blank cell. Simply put, all I am doing is clicking on the cell's handle and filling the blanks (it only fills the cells down until it finds a cell with a value).

    I am tediously going through each range of cells, autofilling down, and working from right to left.

    There must be an easier way where I can select the range of cells, run a macro, and it does the autofill for me.

    Any suggestions?

    Thanks in advance,

    Brock

  2. #2
    Earl Kiosterud
    Guest

    Re: VBA or Macro to auto fill a selected range

    Brock,

    A macro is actually VBA. This is an unusual request, but try this:

    Sub FillCells()
    Dim MyRange As Range, cel As Range
    Set MyRange = Range(Cells(1, 1), Cells(9, 4))
    'Set MyRange = Range("A1:D9")

    For Each cel In MyRange
    If cel.Offset(1, 0) = "" Then cel.Copy Destination:=cel.Offset(1, 0)
    Next cel
    End Sub

    Use the Set MyRange statement that's the most convenient. Set it to your
    range, not including the bottom row.
    --
    SEarl Kiosterud
    www.smokeylake.com

    "Btibert" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Hello everyone,
    >
    > Here is my problem. I have a spreadsheet with four columns, which are
    > variables nested within each other. What I am currently doing is going
    > through a range, finding the blank cells, filling all the blanks with
    > the value of the non-blank cell above it, and filling these blanks
    > until I reach a non-blank cell. Simply put, all I am doing is clicking
    > on the cell's handle and filling the blanks (it only fills the cells
    > down until it finds a cell with a value).
    >
    > I am tediously going through each range of cells, autofilling down, and
    > working from right to left.
    >
    > There must be an easier way where I can select the range of cells, run
    > a macro, and it does the autofill for me.
    >
    > Any suggestions?
    >
    > Thanks in advance,
    >
    > Brock
    >
    >
    > --
    > Btibert
    > ------------------------------------------------------------------------
    > Btibert's Profile:
    > http://www.excelforum.com/member.php...fo&userid=8559
    > View this thread: http://www.excelforum.com/showthread...hreadid=397252
    >




  3. #3
    Registered User
    Join Date
    04-20-2004
    Posts
    17
    I truly appreciate your help. Doing a simple test, it appears as if it does the trick.

    While it may be a strange request, my file that I am working with contains over 5000 rows of data, therefore, the process I was using earlier was quite tedious.

    Regardless, I really appreciate your assistance and thank you for taking the time to assist.

    Thanks,

    Brock

+ 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