+ Reply to Thread
Results 1 to 12 of 12

Need Macro Modification for inserting a row and filling down formulas

  1. #1
    Registered User
    Join Date
    03-28-2013
    Location
    Oklahoma City
    MS-Off Ver
    Excel 2010
    Posts
    4

    Need Macro Modification for inserting a row and filling down formulas

    I have a form to incude retail items to a quote. I created a button at the bottom of the form to enable users to add an additional row if they need to include additional retail items. I used the record Macro function to insert a new row and then fill down the formulas.

    Please Login or Register  to view this content.

    My problem is that the range referenced is Row 8. I have selected that row because it is the last row directly above the button. However if I need to run the macro again, my new row is again in row 8. I want it to where after adding a row previously, I the new row shows up in row 9. How do I get the range to adjust everytime I hit the button to run the macro?

    Please help.

    Thanks!!!!
    Jeremiah
    Last edited by Prophet Warrior; 03-28-2013 at 02:19 PM.

  2. #2
    Forum Contributor Mayda89's Avatar
    Join Date
    09-13-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    192

    Re: Need Macro Modification for inserting a row and filling down formulas

    How do you want to determine the row number?
    Do you want it to be say the last row in column x or something like that?

    Cheers,

  3. #3
    Registered User
    Join Date
    03-28-2013
    Location
    Oklahoma City
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Need Macro Modification for inserting a row and filling down formulas

    Thank you.

    Good question. Would really just like it to be the row directly above the row containing the activation button.

    Currently the button is in row 9, so I used row 8 in the record macro feature. But after running the macro 1 time, the button is now in row 10. If I run again, it inserts the new row in row 8, but I would like it to be row 9. And so on...

  4. #4
    Forum Contributor Mayda89's Avatar
    Join Date
    09-13-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    192

    Re: Need Macro Modification for inserting a row and filling down formulas

    Alright , got it.
    So before using the code, I will ask you to do something:

    Go to the row that contains the activation button, select the whole row, go the "NameBox" (its to the left of the formula bar; it shows the adress of the selected cellls), type MyLastRow in the Name Box and click enter. (or you can use any other name that you like, but I need to know it to adjust the code I'm gonna write accordingly.

  5. #5
    Forum Contributor Mayda89's Avatar
    Join Date
    09-13-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    192

    Re: Need Macro Modification for inserting a row and filling down formulas

    After doing the naming, you can use this code
    Please Login or Register  to view this content.

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Need Macro Modification for inserting a row and filling down formulas

    Hi and welcome to the forum. Unfortunately.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Select your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button).
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  7. #7
    Registered User
    Join Date
    03-28-2013
    Location
    Oklahoma City
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Need Macro Modification for inserting a row and filling down formulas

    Thank you.

    It is still doing the same thing, because I named row 9 "MyLastRow". So the macro still only inserts the new row in row 8 everytime. How do I get the row name to stay with the row that the button is on?

  8. #8
    Registered User
    Join Date
    12-17-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    80

    Re: Need Macro Modification for inserting a row and filling down formulas

    wow, I'm facing the exact same situation this morning as well. Looking forward to seeing the solution.

  9. #9
    Registered User
    Join Date
    12-17-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    80

    Re: Need Macro Modification for inserting a row and filling down formulas

    This isn't mine, I found it on this website: http://dmcritchie.mvps.org/excel/insrtrow.htm

    It will do what we are looking for but not from a button... which I am trying to figure out now.

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor Mayda89's Avatar
    Join Date
    09-13-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    192

    Re: Need Macro Modification for inserting a row and filling down formulas

    Jeremiah,

    I just figured what causes the problem:
    Because we don't insert a whole row, the named range doesnt shift as I intended.
    We can easily fix the problem by changing the range we name.
    So press ctrl + f3 to enter the names menu, and delete the name MyLastRow you gave; then close the naming menu.

    Now instead of naming the whole row as MyLastRow, just select the cells in the row of the button, from column a to t.
    (i.e. if the button is at row 9, select the range a9 to t9), and name this range as MyLastRow.

    Now, the code will work smoothly!

    Take Care,

  11. #11
    Registered User
    Join Date
    03-28-2013
    Location
    Oklahoma City
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Need Macro Modification for inserting a row and filling down formulas

    Thank you so much for the help today. Works like a charm.

  12. #12
    Forum Contributor Mayda89's Avatar
    Join Date
    09-13-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    192

    Re: Need Macro Modification for inserting a row and filling down formulas

    Anytime

+ 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