+ Reply to Thread
Results 1 to 8 of 8

Excel Macro inserts row but does not insert next number in row.

  1. #1
    Registered User
    Join Date
    01-28-2010
    Location
    Denmark, Copenhagen
    MS-Off Ver
    Excel Vista
    Posts
    2

    Excel Macro inserts row but does not insert next number in row.

    G'Day everyone,

    I am trying to put a macro in a spreadsheet that will prompt the user to click the button and for the macro to insert a new row and add to the number above.

    i.e. insert a new row and number it numerically.


    So far...
    Please Login or Register  to view this content.
    Thanks a million for any help.

    Cheers.
    Last edited by Man Help; 01-28-2010 at 11:01 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Excel Macro to Add to Cell Above

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Excel Macro to Add to Cell Above

    I've added code tags this time.

    Your button wil always add a row at Row 27,is this what you want?

  4. #4
    Registered User
    Join Date
    01-28-2010
    Location
    Denmark, Copenhagen
    MS-Off Ver
    Excel Vista
    Posts
    2

    Re: Excel Macro Loop Help

    Yes, row 27 will be the initial input row. The user will then hopefully click the button and a new row will be inserted below with the next number in the series.

    Apologies for the title confusion... clearly an amatuer at this.

    Thanks

  5. #5
    Registered User
    Join Date
    12-17-2023
    Location
    Indianapolis, IN
    MS-Off Ver
    Office Professional Plus 2021
    Posts
    18

    Re: Excel Macro Loop Help

    All you basically need is to load the 1st cell of the new row with "=Row()", not "27". That way as more rows get pushed down cell A1 of each row always shows its row value. Something just past the insert like

    Selection.Insert Shift:=x1Down
    ActiveCell.Range("A1").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "=ROW()"

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,956

    Re: Excel Macro Loop Help

    Quote Originally Posted by cwayneu View Post
    All you basically need is to load the 1st cell of the new row with "=Row()", not "27". That way as more rows get pushed down cell A1 of each row always shows its row value. Something just past the insert like

    Selection.Insert Shift:=x1Down
    ActiveCell.Range("A1").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "=ROW()"
    Perhaps you missed that this thread is almost 13 years old now?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Registered User
    Join Date
    12-17-2023
    Location
    Indianapolis, IN
    MS-Off Ver
    Office Professional Plus 2021
    Posts
    18

    Re: Excel Macro inserts row but does not insert next number in row.

    WOW, yes I did miss that. OOPS. I'll check that from now on. (LOL)

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,956

    Re: Excel Macro inserts row but does not insert next number in row.

    haha no problem, I have done that myself a few times already

+ 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