+ Reply to Thread
Results 1 to 16 of 16

Need simple way to insert new row

  1. #1
    Registered User
    Join Date
    03-10-2010
    Location
    Hendersonville, TN USA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Need simple way to insert new row

    I have a spreadsheet of safety incidents by date. I would like a simple way to insert a new row at top with all formatting for these fields intact. I know I could simply enter the new row at the bottom, but I would like the newest events at top. Is there a simple way? By simple I mean without VB.


    Attachment 432593
    Attached Images Attached Images

  2. #2
    Registered User
    Join Date
    09-10-2011
    Location
    TRICHY INDIA
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Need simple way to insert new row

    Hi,
    Just insert (ctl + ) and use the format painter brush.

  3. #3
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: Need simple way to insert new row

    You could have an empty row under your headings formatted appropriately and hide it, then when you insert a row on the first row of data the formatting will remain correct.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  4. #4
    Registered User
    Join Date
    03-10-2010
    Location
    Hendersonville, TN USA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Need simple way to insert new row

    Thanks for the reply. As you state I can do this easily withe ctrl+Shift + to insert a new row. Then a dialog allows me to select format painter of the line above or the line below. That works perfectly. Now I want to record this in a macro. When I do the exact same selections and record it the results are not even close. Something really wrong happens with I select paint line below formats. Is there a selection on the ribbon to copy the format of the line below?

  5. #5
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: Need simple way to insert new row

    Hello
    Select the row, here I suppose it's Row 2 and try the following code:

    Please Login or Register  to view this content.
    DBY

  6. #6
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Need simple way to insert new row

    If what you have is a table, right click on the first row of data and click on Insert, Table Rows Above. All formatting and formulae of the rows beneath the new row will be applied.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  7. #7
    Registered User
    Join Date
    03-10-2010
    Location
    Hendersonville, TN USA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Need simple way to insert new row

    Quote Originally Posted by DBY View Post
    Hello
    Select the row, here I suppose it's Row 2 and try the following code:

    Please Login or Register  to view this content.
    DBY
    OK. So now I am in to visual basic which I have ZERO experience. That said, I have always wanted to learn this. Would you mind spoon-feeding step by step on how I would enter the code? Do I go to the macro i recorded and edit it?

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

    Re: Need simple way to insert new row

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button

  9. #9
    Registered User
    Join Date
    03-10-2010
    Location
    Hendersonville, TN USA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Need simple way to insert new row

    Thank you for the step by step Pepe. I was able to install the code and it did work, but it did not do what I wanted it to do. The steps I want to perform in a macro would be:
    1. Select row 3
    2. Insert Row
    3. Copy formats from row below

    expanded.jpg

    The VBA code provided did not do this. Can you help?

  10. #10
    Forum Contributor
    Join Date
    03-10-2013
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Need simple way to insert new row

    Dear SJMaye!
    Here's a sample. I hope it will be good. Press Ctrl-b and ready.

    Have a nice day!

    <---------If you like someone's answer, click the star to give them a reputation point for that answer.
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Need simple way to insert new row

    Quote Originally Posted by SJMaye View Post
    The VBA code provided did not do this.
    What did the code actually do?

    See if this works.

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    03-10-2010
    Location
    Hendersonville, TN USA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Need simple way to insert new row

    Quote Originally Posted by Pan314 View Post
    Dear SJMaye!
    Here's a sample. I hope it will be good. Press Ctrl-b and ready.

    Have a nice day!

    <---------If you like someone's answer, click the star to give them a reputation point for that answer.
    Hello

    That works perfectly on your sample. I got unusual results when I added the code to my file and tried the macro. Weird thing is after I deleted several extra columns to the right the code worked perfectly. There must be something wrong with those columns causing this behavior. I will troubleshoot.

  13. #13
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Need simple way to insert new row

    Quote Originally Posted by SJMaye View Post
    There must be something wrong with those columns causing this behavior. I will troubleshoot.
    Merged cells?

  14. #14
    Forum Contributor
    Join Date
    03-10-2013
    Location
    Budapest, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Need simple way to insert new row

    Dear SJMaye!

    It has to work! I do not understand what happened. Send in your own file.I type in the code and sends it back.
    Maybe I figure out the cause of the odd behavior

    Bye!

  15. #15
    Registered User
    Join Date
    03-10-2010
    Location
    Hendersonville, TN USA
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Need simple way to insert new row

    Hi All,

    Sorry for the late reply. I was driving back from TN to WI yesterday (Thanksgiving). I would like to include a copy of the file like Pan requested, but it would do no good. I deleted the columns that were causing the problem. The code works now. I will rebuild the columns. I feel confident these columns had some sort of merging going on, although I cannot be sure. This was someone else's file I have been working with.

    I will continue to work on it. If during the column rebuild the issue comes back I will come back to you. Thank you all for your help.

  16. #16
    Registered User
    Join Date
    01-21-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Need simple way to insert new row

    I have found a tutorial which can interest you: adding rows automatically

+ 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. Simple macro to conditionally insert a row?
    By Cam in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-13-2014, 03:47 PM
  2. Replies: 1
    Last Post: 01-22-2012, 11:44 AM
  3. Simple insert value into cell
    By eonizuka in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-06-2009, 06:51 PM
  4. Replies: 4
    Last Post: 03-10-2006, 04:40 AM
  5. [SOLVED] Need Simple Copy and Insert Row, Move Down Macro
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-24-2006, 12:25 PM
  6. [SOLVED] How do i insert a simple checkable box (<2.57 columng width)?
    By LostinKtown in forum Excel General
    Replies: 5
    Last Post: 09-12-2005, 08:24 PM
  7. [SOLVED] Simple Question (insert new line)
    By Joe D in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-27-2005, 11:05 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