+ Reply to Thread
Results 1 to 6 of 6

Code to add rows and continue formulas

  1. #1
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Code to add rows and continue formulas

    Im looking to create a userform to add new rows to a sheet, and continue the formulas in certain columns.
    The user starts by entering a number in the text box tbRowAdd. When the user clicks on the button called btAdd it first checks to make sure the number entered is equal to or between 1 and 1500. If this is not the case it should display a message box saying "You must enter a valid number from 1 to 1500 in the tex box."
    If the number is valid it should then add that amount of rows below the current active cell in the worksheet ReturnData.
    It should then continue the formulas in the A, B, C and F columns. The formulas are as follows:

    A: =IFERROR(IF($D6="", "", ROW($A6)-ROWS($A$1:$K$5)),"")

    B: =IFERROR(RANK($C6,$C$6:$C$99986, 1),"")

    C: =IFERROR(IF(OR(AND(ReturnData!$D6>=Search!$E$1, ReturnData!$D6<=Search!$E$2),OR(Search!$E$1="", Search!$E$2="")), IFERROR(SEARCH(Search!$E$3,$E6,1),"")-(-IFERROR(SEARCH(Search!$E$4,$F6,1),""))-(-IFERROR(SEARCH(Search!$E$5,$G6,1),""))-(-IFERROR(SEARCH(Search!$E$6,$H6,1),""))-(-IFERROR(SEARCH(Search!$E$7,$I6,1),""))+ROW()/100000, ""), "")

    F: =IFERROR(VLOOKUP($G6, EquipmentData!$B$3:$C$1048576, 2, FALSE),"")

    Each number in bold should match the row number (I dont know if this happens automatically or requires coding)

    Thanks,
    James

  2. #2
    Valued Forum Contributor
    Join Date
    12-25-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2016
    Posts
    506

    Re: Code to add rows and continue formulas

    Hi Nitefox, have you tried copying the last row (seems like row 6 from your post) and pasting them to new rows, instead of creating them?



    _______________________________________________________________________________________________________________________________
    1. Click on the * Add Reputation if you think someone helped you
    2. Mark your thread as SOLVED when question is resolved

    Alvin

  3. #3
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: Code to add rows and continue formulas

    Row 6 is the first row. There are a couple of thousand records (and growing). Im looking to mainly use this code for adding rows in-between.

  4. #4
    Valued Forum Contributor
    Join Date
    12-25-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2016
    Posts
    506

    Re: Code to add rows and continue formulas

    Perhaps inserting blank rows-in-between, then copy the last row (before the first inserting blank row) and paste it to the blank rows-in-between?



    _______________________________________________________________________________________________________________________________
    1. Click on the * Add Reputation if you think someone helped you
    2. Mark your thread as SOLVED when question is resolved

    Alvin

  5. #5
    Forum Contributor
    Join Date
    09-16-2013
    Location
    Los Angeles, USA
    MS-Off Ver
    Excel 2011
    Posts
    620

    Re: Code to add rows and continue formulas

    I dont want to copy the values just the formulas.

  6. #6
    Valued Forum Contributor
    Join Date
    12-25-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2016
    Posts
    506

    Re: Code to add rows and continue formulas

    Yea, copying cell/range (not .value) will retain the formula.



    _______________________________________________________________________________________________________________________________
    1. Click on the * Add Reputation if you think someone helped you
    2. Mark your thread as SOLVED when question is resolved

    Alvin
    Last edited by alvin-chung; 01-26-2014 at 10:20 PM.

+ 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. [SOLVED] Last instance - Insert Row - Continue formulas Project
    By Fett2oo5 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-14-2013, 10:53 AM
  2. Macro - Insert Row and continue formulas
    By Fett2oo5 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2013, 11:38 AM
  3. Replies: 5
    Last Post: 01-24-2012, 08:54 PM
  4. [SOLVED] Textbox and label formulas-continue
    By damorrison in forum Excel General
    Replies: 3
    Last Post: 03-12-2006, 02:35 PM
  5. Allow code to continue regardless
    By Pat in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2005, 11:06 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