+ Reply to Thread
Results 1 to 4 of 4

Dynamic VB code for Autofill

  1. #1
    Registered User
    Join Date
    06-22-2014
    Location
    Harrisburg, PA
    MS-Off Ver
    MS Office 2007
    Posts
    2

    Dynamic VB code for Autofill

    It has been a while since I worked with VB and I am struggling with some simple code.

    I have an Excel sheet that I am using to track client information on, the client name starts on A3 and the list of clients we are tracking will vary from week to week.

    I have values in B3:D3 that I need to auto fill based on the values that I have in column A. For example, if column A goes to row 33 then I want to auto fill B3:D3 down to row 33.

    The code that I have now works as band aid, but I need something more dynamic.

    I have found some solutions on line but none of them worked on varying lengths, the following is the code that has worked so far.

    Sub Autofill()
    '
    ' Autofill Macro
    '
    Range("B3:D3").Select
    Selection.Autofill Destination:=Range("B3:D36")
    Range("B3:D36").Select
    Range("B3").Select
    End Sub

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Dynamic VB code for Autofill

    There is no need to select
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    06-22-2014
    Location
    Harrisburg, PA
    MS-Off Ver
    MS Office 2007
    Posts
    2

    Re: Dynamic VB code for Autofill

    Mike,

    Thank you for the response.

    The code you gave me needed one tweak to it:

    Range("B3:D3").AutoFill Destination:=Range(Range("B3:D3"), Cells(Rows.Count, 1).End(xlUp).Offset(0, 1))

    I am posting this so that hopefully someone can use this code, it will come in very handy.

  4. #4
    Registered User
    Join Date
    04-08-2014
    Location
    Italy
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Dynamic VB code for Autofill

    Hey, Victors.

    I am just a regular financial/accountant user, I dont know how to program in VBA and I never done something by myself eventhough I studied programming.

    I was seeking for a subject using the search tool and I ended up here in your topic. I would like to give you a hand as I had the same need and I managed to get it done using this code:

    Range("A2").Select
    Selection.End(xlDown).Select
    ActiveCell.Offset(0, 12).Select
    Range(Selection, Selection.End(xlUp)).Select
    Selection.FillDown

    Hope this can helps and I apologise if this can't help you (it worked out for me).

    Cheers.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Dynamic Autofill
    By Dan27 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2013, 10:30 AM
  2. VBA Code - Autofill with a Dynamic Range
    By Jurij in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-24-2013, 02:27 AM
  3. VBA code to autofill until dynamic cell
    By JPSN in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-11-2013, 06:59 AM
  4. Need help with dynamic autofill
    By oldmanexcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2013, 11:36 AM
  5. [SOLVED] Dynamic autofill VBA
    By Siglen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2012, 01:10 AM

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