+ Reply to Thread
Results 1 to 6 of 6

auto-increment formula

  1. #1
    Registered User
    Join Date
    07-01-2019
    Location
    Virginia
    MS-Off Ver
    Pro Plus 2016
    Posts
    22

    Red face auto-increment formula

    TLDR: terminating a formula that increments based on a variable value with another formula without using any built-in functions/commands/methods


    Hi all,

    I'm trying to auto-increment and terminate a formula based on a variable value.

    For example, cell A6 has a value of 26.
    In column B, I would like a formula to start at cell B2, increment to cell B27, and then stop.
    Next, if I were to change A6 to something like 45, the formula in column B would automatically extend to B46.
    Rather than returning a 0-length string or a 0 in cell B28/B46 and beyond, I would like for cell B28 to be completely blank, no formula or anything.
    I'm trying to do all this via a formula or formulas, so not using any built-in functions/commands.

    I know you can just drag to fill the formula down a column, but I'm dealing with hundreds of rows and will be repeating this step on many many sheets and am trying to automate this process.
    I would rather not have to use VBA here, but if no other solutions are possible, then that's fine.

    Thank you.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: auto-increment formula

    Welcome to the Forum richx !

    Rather than returning a 0-length string or a 0 in cell B28/B46 and beyond, I would like for cell B28 to be completely blank, no formula or anything.
    Excel is a function-based language. That is, every cell must either: be empty, have a formula, or have a value. You cannot have a cell that is empty, and then later magically has a formula.

    Your problem can be solved with formulas--up until you say that you want unused cells to be completely blank with no formula. If that's what you want, the only way to do it is with VBA.

    If you would a like a VBA solution please describe what values or formulas you want to see in B2:B27 (as in your initial condition).
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    07-01-2019
    Location
    Virginia
    MS-Off Ver
    Pro Plus 2016
    Posts
    22

    Smile Re: auto-increment formula

    Thank you for the response!

    Just curious if there was a way to avoid using VBA initially.

    The formula I'm using in column B is
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    with cell A3 being the name of the workbook I want to copy entries from. In cell A12 I have the number of rows with non-empty cells in the original workbook, which is 717 in this case. I would like for the formula in column B to extend all the way to row 718. I will be using similar formulas for columns C through Z.
    Last edited by richx; 07-02-2019 at 09:18 AM.

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: auto-increment formula

    Like =IF(ROW()<=$A$12+1,INDIRECT($A$3&"B"&ROW()),"")
    (starting in row 2)?

  5. #5
    Registered User
    Join Date
    07-01-2019
    Location
    Virginia
    MS-Off Ver
    Pro Plus 2016
    Posts
    22

    Re: auto-increment formula

    yes exactly! in VBA

    but I would like to change the "" zero-length strings at the end of the formula to blank cells.
    Since I will be sorting the rows alphabetically later, and do not want "empty" cells at the top of my spreadsheet.
    Last edited by richx; 07-02-2019 at 10:00 AM.

  6. #6
    Registered User
    Join Date
    07-01-2019
    Location
    Virginia
    MS-Off Ver
    Pro Plus 2016
    Posts
    22

    Re: auto-increment formula

    my solution at the moment is to return a zero if the indirect returns false, and then record a macro to filter the zeros and clear those cells, then sort alphabetically, but is there a more efficient way?

+ 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. how to auto increment integer within vlookup formula?
    By gdallas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-12-2016, 07:19 AM
  2. Auto Increment Formula
    By bgates in forum Excel General
    Replies: 5
    Last Post: 12-31-2014, 10:32 AM
  3. Auto increment a cell/formula every 2 weeks
    By Technobrarygeek in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-16-2014, 11:39 AM
  4. [SOLVED] Auto Increment formula issue
    By robpopper in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-13-2013, 01:30 PM
  5. [SOLVED] How to auto-increment integers within a formula
    By vikefan82 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-23-2012, 04:24 PM
  6. auto increment from linked formula problem
    By twmtwp in forum Excel General
    Replies: 5
    Last Post: 08-26-2009, 10:32 AM
  7. Auto Fill Increment Formula
    By nfasciana in forum Excel General
    Replies: 3
    Last Post: 04-05-2005, 04:07 PM

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