+ Reply to Thread
Results 1 to 8 of 8

Insert X rows Macro modification

  1. #1
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Insert X rows Macro modification

    Hi
    Please show me how to modify the following macro so that the rows inserted in that column are selected and the OPTION BOX to format as above, below or clear formatting is shown.

    Thanks!

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Insert X rows Macro modification

    Here's one way

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Insert X rows Macro modification

    That neither selects inserted rows nor presents the formatting option box.
    See the difference between running the macro, and inserting the rows by the menu commands.
    Attached Images Attached Images

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Insert X rows Macro modification

    Your original macro didn't select cells and neither does mine. They both USE what happens to be selected when you run the macro, the only difference is your macro accepts a range of cells and then you use a loop to process the cells. A loop is not necessary since you're specifying the number of rows to insert. Hence I simplified and removed the loop (loops should always be avoided if possible since they are not efficient in terms of overhead time when large ranges are involved).

    Neither am I clear what you mean by the formatting option box. It's standard Excel functionality to carry the formatting on the selected row to rows you introduce. Or it is on Excel 2007 --->

    Maybe it's because you apparently have Excel 2002. In which case try adding the copyorigin instruction.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Insert X rows Macro modification

    The formatting option box is the brush icon that appears in one of the above pictures.

    May I have a choice by means of a drop down to choose the CopyOrigin?

    edit: and modify in order to select inserted rows?

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Insert X rows Macro modification

    Hi,

    Maybe

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Insert X rows Macro modification

    A,a,B,b inserts row BELOW selection and formats as BELOW. It should insert row above selection and then if A,a format as above, if B,b format as below.

    C,c inserts row BELOW selection and clears formatting. It should insert row above selection and clear formatting.

    Inserted rows still are not selected after macro end.

  8. #8
    Forum Contributor
    Join Date
    01-20-2014
    Location
    Greece
    MS-Off Ver
    20 yr. old Excel 2002!
    Posts
    710

    Re: Insert X rows Macro modification

    This works ok.
    The function of selecting the inserted rows on macro end is still wanted.

    Please Login or Register  to view this content.

+ 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] Macro to insert specific number of rows, populate rows with data above except date
    By Melissa Camp in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-08-2015, 03:59 PM
  2. [SOLVED] Insert row macro modification
    By makinmomb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-25-2014, 11:23 AM
  3. Insert date for last workSHEET modification
    By bethanj93 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-18-2014, 05:48 AM
  4. Replies: 0
    Last Post: 11-12-2013, 04:56 PM
  5. [SOLVED] Macro code to insert 3 rows on spreadsheet with variable number of rows
    By D18GE in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-17-2013, 07:33 AM
  6. Replies: 0
    Last Post: 05-10-2013, 12:04 PM
  7. Replies: 2
    Last Post: 04-21-2011, 07:13 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