+ Reply to Thread
Results 1 to 2 of 2

VBA code to insert multiple non consecutive rows based on selected rows within a table

  1. #1
    Registered User
    Join Date
    09-18-2020
    Location
    Charlotte, NC
    MS-Off Ver
    Office 365 version 1907
    Posts
    3

    VBA code to insert multiple non consecutive rows based on selected rows within a table

    Hi, I currently have the code below that will insert rows into a protected sheet base on the row/rows selected by the user. I added a command to the Context Menu to run this macro when the user right clicks on a row number. It works very well except when the user selects multiple nonconsecutive rows, I get a " Run-time error '1004': Insert method of Range class Failed". I believe this is due to the fact that excel does not let you insert multiple rows when within a Table. Although I would love for the user to be able to add these rows as selected, the biggest problem I have with this is that the sheet is left unprotected after the error is received.



    Is there any way to modify this code to allow the user to insert multiple non-consecutive rows when a table is used? If not, how would I modify the code to either give the user a megbox stating that they cannot add the rows as selected, or at a minimum how would I add code to protect the sheet prior to erroring out?

    This thread is cross-posted at https://www.mrexcel.com/board/thread...table.1157620/

    Thanks,



    Please Login or Register  to view this content.
    Last edited by 6StringJazzer; 01-06-2021 at 04:01 PM. Reason: Added cross-post link

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    1,849

    Re: VBA code to insert multiple non consecutive rows based on selected rows within a table

    Possibly...
    Please Login or Register  to view this content.
    ____________________________________________________________
    If I've been helpful, let me know. If I haven't, let me know that too.

+ 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. Insert blank rows above a table based on unique values in one of the columns in the table
    By carlito2002wgn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-06-2019, 07:52 PM
  2. Insert rows for multiple selected rows
    By JN12345 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-25-2018, 04:18 PM
  3. Return indexes of rows when multiple rows of a table are selected.
    By samkumar in forum Word Programming / VBA / Macros
    Replies: 0
    Last Post: 08-12-2013, 04:54 AM
  4. Code to insert rows between selected cells
    By DeepakS in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-07-2013, 08:18 AM
  5. [SOLVED] Insert Multiple Rows Based Off Number in Cell and Copy Data From Above New Rows
    By tstell1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2012, 04:15 PM
  6. Non-Consecutive Rows sort data with multiple rows
    By Keiran1983 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2010, 11:15 PM
  7. [SOLVED] Inserting multiple rows in excel with data in consecutive rows
    By technotronic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-20-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