+ Reply to Thread
Results 1 to 7 of 7

Move data from a userform to a table but getting error

  1. #1
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Move data from a userform to a table but getting error

    Hi,

    Here is my code

    Please Login or Register  to view this content.
    This code works fine when run once and it adds my new data but if I run it again with more data I get an error application defined or object error and it highlights "Set lastRow = .ListRows.Add"

    Is there a better way to add a row to a table and add values to that new row?

    Thanks

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: Move data from a userform to a table but getting error

    In the attached is the usual method/code I apply to addition/removals.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Move data from a userform to a table but getting error

    Hi Torachan,

    Thanks for sharing your file. It works exactly how I need it to but when I use the codes and adapt it to my worksheet I am still getting runtime errors when adding more than two new rows.

    Would this be anything to do with memory usage and is there any way I can fix this?

    Thank you for your help

  4. #4
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,301

    Re: Move data from a userform to a table but getting error

    To your first question - post #1
    Before reusing "Set lastRow = .ListRows.Add" you should release the object assignment (Set lastRow = Nothing) or use scheme with "With ... End With"

    To your second question - post #3
    Show your-torachan code adaptation

  5. #5
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Move data from a userform to a table but getting error

    Hi poruchu vevrku,

    Thanks for taking the time to reply. Where would I place "Set lastRow = Nothing", does it matter? or With and End With. I have tried putting Set lastRow = Nothing after End With but I am still getting a runtime error. Here is the full code I have used.

    Please Login or Register  to view this content.
    I have used Torachan codes and changed things like table names and sheet names to suit my worksheets but I still get a runtime error after I have added several new rows to the table. Also I have another table below this table would that affect anything?

    Would adding a row to the top of the table rather than the bottom be a better option or insert entire row?

    Thanks
    Last edited by colin7; 02-09-2020 at 04:42 PM.

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: Move data from a userform to a table but getting error

    Hi Colin7
    Just seen this post, I think you have possibly answered your own question.
    Your upper table is probably trying to run into the lower table.
    If you are still having trouble post a de-sensitised copy of your file.
    I have applied this approach to many apps and never encountered problems.
    torachan.

  7. #7
    Registered User
    Join Date
    06-27-2019
    Location
    UK
    MS-Off Ver
    2010
    Posts
    98

    Re: Move data from a userform to a table but getting error

    Hi Torachan,

    Thanks for your help with this. I added the new row to the top of the table which seems to have fixed the problem.

    thank you

+ 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. Move data from 1 table to another table, then clear the original table
    By kwoltman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-03-2019, 06:06 PM
  2. [SOLVED] Userform/VBA extract records from table and move to new sheet
    By hopegriffin in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-11-2015, 11:05 PM
  3. [SOLVED] Code to move data from an entry table to a historical table by date.
    By rlh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-17-2014, 11:04 AM
  4. Filter data based on data in textboxes in userform and move to a new workbook
    By puuts in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-06-2014, 04:44 PM
  5. To move the values from excel userform to Access table using vba
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2009, 09:47 AM
  6. How to move data from userform to userform and save?
    By artromanov in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-02-2007, 03:09 AM
  7. [SOLVED] Data Validation Cell - Move to UserForm
    By thom hoyle in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-27-2005, 08: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