Consulting

Results 1 to 10 of 10

Thread: Solved: Dynamic Autofill?

  1. #1
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location

    Solved: Dynamic Autofill?

    Hello,

    How possible is it to have a dynamic autofill?

    [vba]
    Selection.AutoFill Destination:=Range("k1:K70")
    [/vba]

    After I do the first autofill, I would then be filling 71 to 120, then 121 to 160 etc. ?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Autofill must include the cell to fill from

    [vba]

    Range("K1").AutoFill Destination:=Range("k1:K70")[/vba]

  3. #3
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location
    Quote Originally Posted by xld
    Autofill must include the cell to fill from

    [vba]

    Range("K1").AutoFill Destination:=Range("k1:K70")[/vba]
    [vba]
    Range("K1")
    [/vba]

    I have that part as dynamic already


    However, ("k1:K70") , is there a way to say something like ("activecell:k70")?

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Range(Activecell,Cells(70,Activecell.Row)).Autofill
    [/vba]

  5. #5
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location
    Range(Activecell,Cells(70,Activecell.Row)).Autofill

    The .Autofill comes up as argument not optional.

  6. #6
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]ActiveCell.AutoFill Range(ActiveCell, Cells(70, ActiveCell.Column))[/VBA]
    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'

  7. #7
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location
    Ok , great.

    [vba]
    ActiveCell.AutoFill Range(ActiveCell, Cells(70, ActiveCell.Column)) [/vba]
    this worked out great for filling from the active cell. How possible is to have the 70 part , dynamically fill to the end of the column to the left of it instead of just 70?

  8. #8
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]ActiveCell.AutoFill Range(ActiveCell, Cells(Rows.Count, _
    ActiveCell.Column - 1).End(xlUp).Offset(, 1))
    [/VBA]

    Of course, if the data in the adjacent column is continous, you just need to double click the Fill button of the active cell.
    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'

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by debauch
    Range(Activecell,Cells(70,Activecell.Row)).Autofill

    The .Autofill comes up as argument not optional.
    I answered the question, you were supposed to combine it with my previous reply.

  10. #10
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location
    Thank-you. I was able to join the feed with the additional columns. 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
  •