+ Reply to Thread
Results 1 to 8 of 8

Adding a Table Row Doesn't Work Immediately After Deleting All Rows

  1. #1
    Forum Contributor
    Join Date
    04-23-2014
    Location
    United Kingdom
    MS-Off Ver
    Microsoft 365
    Posts
    149

    Adding a Table Row Doesn't Work Immediately After Deleting All Rows

    I have a procedure that deletes all rows in a table, and I have another that adds a row. The problem is when I run DeleteAllRows and then AddRow immediately after, it doesn't work the first time. It only works on the second run.

    Why is this and what is the solution?

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,299

    Re: Adding a Table Row Doesn't Work Immediately After Deleting All Rows

    This will give you a better understanding...
    You are in fact wanting to add data to the first empty row...
    listrows.add references available empty row...
    Please Login or Register  to view this content.
    Last edited by sintek; 04-21-2022 at 05:21 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    04-23-2014
    Location
    United Kingdom
    MS-Off Ver
    Microsoft 365
    Posts
    149

    Re: Adding a Table Row Doesn't Work Immediately After Deleting All Rows

    I can see what's happening now, but I don't want to add any data to the table. I just want AddRow to add a second body row first time.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,299

    Re: Adding a Table Row Doesn't Work Immediately After Deleting All Rows

    ......Processing....

  5. #5
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2404-17531.20128
    Posts
    1,361

    Re: Adding a Table Row Doesn't Work Immediately After Deleting All Rows

    Imagine that even though the table looks to have a row it hasn't, with that in mind when you run it the first time it adds a row but you don't see it. It is only when you add the second row that you see the animation of the new row being added.

    You can see that by running Sintek's code but if you want the first row to remain blank then maybe a slight change like:
    Please Login or Register  to view this content.
    If things don't change they stay the same

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,299

    Re: Adding a Table Row Doesn't Work Immediately After Deleting All Rows

    Manipulated....
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,239

    Re: Adding a Table Row Doesn't Work Immediately After Deleting All Rows

    Statto, this is an optical illusion.
    When you delete all the rows of the table it has no rows, even though you see the first row on the sheet. This empty row can be called the " encouragement row". I think this is even better illustrated by the code below.
    Please Login or Register  to view this content.
    Artik

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,299

    Re: Adding a Table Row Doesn't Work Immediately After Deleting All Rows

    Thanks for rep + ... Glad to have helped...

+ 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. Replies: 8
    Last Post: 03-13-2023, 03:09 PM
  2. [SOLVED] Deleting/Adding rows from source data outputs "#REF" error in the consolidated table
    By Dadashvespek in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-05-2020, 03:33 AM
  3. [SOLVED] Adding Hyperlinks to the names of sheets - the formula doesn't work
    By Vitalite in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 06-23-2017, 08:20 AM
  4. [SOLVED] Adding a row below the active cell - doesn't always work first time
    By kissarmy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-17-2017, 06:48 PM
  5. Adding columns doesn;t work
    By edwardag in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 10-25-2012, 11:18 AM
  6. Replies: 1
    Last Post: 01-29-2006, 02:50 AM
  7. Excel 97 - Adding Every 8th Row - Formula should work, but doesn't
    By Damaeus in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-23-2005, 01:06 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