+ Reply to Thread
Results 1 to 4 of 4

Runtime Error when inserting new row into table.

  1. #1
    Registered User
    Join Date
    04-25-2018
    Location
    Nashville, TN
    MS-Off Ver
    2016
    Posts
    34

    Runtime Error when inserting new row into table.

    Hello,

    I have a small VBA macro which generates a unique employee ID based on whether they are full employees, from temp agency A and temp Agency b. I have attached a sample spreadsheet showing what I have thus far. The code is as follows...
    Please Login or Register  to view this content.
    Currently I can create a new row at the bottom of the table with no error. However when I attempt to insert a new row in the middle of the table, my VBA throws runtime error: 1004. Please assist me troubleshooting this problem as I am extremely new to VBA.

    Thank you in advance.

  2. #2
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: Runtime Error when inserting new row into table.

    Jekeith,

    Split your "If" codeline to the following
    Please Login or Register  to view this content.
    HTH,
    Maud

  3. #3
    Registered User
    Join Date
    04-25-2018
    Location
    Nashville, TN
    MS-Off Ver
    2016
    Posts
    34

    Re: Runtime Error when inserting new row into table.

    That did it for me. If you don't mind my asking...why did that make a difference?

  4. #4
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: Runtime Error when inserting new row into table.

    Hu Jekeith,

    "Target.Offset(0, 1)" is not defined when making a change to an entire row (insert). Splitting the code line allows "If Target.Cells.Count > 1 Then Exit Sub" to process and exit the routine before the following line containing "Target.Offset(0, 1)" can execute.

    HTH,
    Maud

+ 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. Pivot Table Runtime error 1004
    By Code Flunkie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-01-2017, 05:39 PM
  2. [SOLVED] Runtime error 13 type mismatch when inserting columns
    By ChrisAdl in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-09-2013, 11:27 PM
  3. Macro from filtered pivot table runtime error
    By dentdntn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-28-2012, 11:25 AM
  4. HELP! Runtime error 13 Sending two non-contiguous rows as a table
    By g1987 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-15-2012, 05:49 PM
  5. Runtime error 438 in Pivot table macro
    By DavidBW in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 01-10-2012, 11:12 AM
  6. Intermittent Runtime Error when inserting picture
    By vamosj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-20-2009, 04:36 AM
  7. Pivot table giving 'runtime error 1004'
    By wantucce in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-21-2007, 01:47 PM

Tags for this Thread

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