+ Reply to Thread
Results 1 to 4 of 4

Dynamic autofill VBA

Hybrid View

Siglen Dynamic autofill VBA 08-30-2012, 04:48 AM
NickyC Re: Dynamic autofill VBA 08-30-2012, 05:45 AM
Marrosi Re: Dynamic autofill VBA 08-30-2012, 05:52 AM
Siglen Re: Dynamic autofill VBA 08-31-2012, 01:10 AM
  1. #1
    Registered User
    Join Date
    03-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    Excel 2007
    Posts
    18

    Dynamic autofill VBA

    Hi,

    I have a document where I every month collect a lot of data in columns A:J.

    In column K, I have a formula which I want to autofill from cell K2 until the last row (row 1 are just headers..) The formula is already typed into K2.

    The volume of data varies from month to month. So I want the macro to be dynamic.

    If there is data from row 2 until row 50 I want the formula to be autofilled until row 50 only.

    If there is data from row 2 until row 70, autofilled until row 70...

    Any suggestions how to do this?

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Dynamic autofill VBA

    Hi
    try this macro

    this assumes that only cells K1 and K2 are populated in column K - there is no need to delete old values
    is this correct?

    Sub Macro1()
    Dim Coln As Long, Lastrow As Long
    
    'establish the last populated cell in columns A:K
    Lastrow = 2
    For Coln = 1 To 11
        If ActiveSheet.Cells(Rows.Count, Coln).End(xlUp).Row > Lastrow Then Lastrow = ActiveSheet.Cells(Rows.Count, Coln).End(xlUp).Row
    Next Coln
    
    'Populate into column k
    Range("K2").Copy Destination:=Range("K3", Columns("K").Rows(Lastrow).Address)
    
    End Sub

  3. #3
    Registered User
    Join Date
    10-08-2008
    Location
    Belgium
    MS-Off Ver
    2010
    Posts
    6

    Re: Dynamic autofill VBA

    Hope this can help in one or anoher way.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    03-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Dynamic autofill VBA

    Thank you guys!

    I actually used both of your solutions in my model, and both macros are helping me to do exactly what I wanted them to do! :-)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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