Consulting

Results 1 to 4 of 4

Thread: Fill Down Automatically?

  1. #1

    Fill Down Automatically?

    I need to fill in values (in same column) as in this example
    so that 7533 would be filled down to the next cell containing text.
    This is the same as selecting the cell containing and down, then pressing ctl+D, except I want a more automated command or macro to do this.
    Seems easy....can it be done? Thanks!

    A 7533

    B

    C

    D 6588

    E

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    This should do it

    [vba]

    Dim iLastRow As Long
    Dim iNext As Long
    Dim i As Long

    With ActiveSheet

    i = 1
    iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    Do Until i >= iLastRow
    iNext = .Cells(i, "A").End(xlDown).Offset(-1).Row
    .Cells(i, "A").AutoFill .Cells(i, "A").Resize(iNext - i + 1)
    i = iNext + 1
    Loop
    End With
    [/vba]

  3. #3
    Thank you

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi SunKitty,
    If this is solved, you can mark it so using the Thread Tools drop-down
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •