+ Reply to Thread
Results 1 to 3 of 3

Macro for autofilling based on cell value

  1. #1
    Registered User
    Join Date
    08-27-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007/2010
    Posts
    1

    Macro for autofilling based on cell value

    Hey first time poster and new to VBA. I am trying to get the macro to run an auto fill of a series from 0-x from say,...cell i3 to i(x+3). Make sense? x being the value in a particular cell say,....cell b2. The value in b2 is user defined and can be changed, but I want changing this to automatically update the fill range... can you help?

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Macro for autofilling based on cell value

    Maybe you could post a workbook example with a before and after to illustrate your question.
    Martin

  3. #3
    Forum Contributor wallyeye's Avatar
    Join Date
    05-06-2011
    Location
    Arizona
    MS-Off Ver
    Office 2010, 2007
    Posts
    308

    Re: Macro for autofilling based on cell value

    You can actually just fill the entire range with the same formula at one shot, Excel will adjust the formula as per relative/absolute references:

    Please Login or Register  to view this content.
    or whatever your formula is. If you want the value in B2 to drive the length of the formula, you could use the worksheet_change event:

    Please Login or Register  to view this content.
    Just pay attention to the absolute/relative referencing in your formula. Here, cell B3 is locked in, A3 will vary with the position of the formula.

    Edit:


    Hmmmm...

    If you decrease the value in B2, you might want to drop the trailing formulas:

    Please Login or Register  to view this content.
    Put this right after the "ActiveSheet... =" line.
    Last edited by wallyeye; 08-27-2012 at 06:07 PM.

+ 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