Results 1 to 8 of 8

Error when run the code a second time without Re-opening the workbook

Threaded View

  1. #1
    Registered User
    Join Date
    10-09-2022
    Location
    London
    MS-Off Ver
    2016
    Posts
    6

    Error when run the code a second time without Re-opening the workbook

    Hi all,

    If I open the workbook and run the below code, it runs fine. However if I run the form and run the code a second time without reopening the workbook, I get method add of object listrows failed. I have added the listbox resource to UserForm_Initialize, any ideas?

     Private Sub CmdAddEng_Click()
    
    Dim Sh As Worksheet
    Dim table_List_Object As ListObject
    Dim table_object_Row As ListRow
    
    Set Sh = Sheets("Engineers")
    Set table_List_Object = Sh.ListObjects(1)
    Set table_object_Row = table_List_Object.ListRows.Add
    
    table_object_Row.Range(1, 1).Value = TxtEngName.Text
    
    If ChkContractor.Value = True Then
        
        table_object_Row.Range(1, 2).Value = TxtEngName.Text
        
    End If
    
    End Sub
    Attached Files Attached Files
    Last edited by gary lawrence; 10-09-2022 at 09:52 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Run time error 91 when opening workbook via vba
    By pratikshah84 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2015, 10:39 AM
  2. [SOLVED] Opening new workbook and pasting values into current workbook - code issues
    By Stew1234 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-15-2014, 07:56 AM
  3. [SOLVED] Method 'Range' Error When Code is Run Automatically When Opening Workbook
    By TBrooker in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 06-26-2013, 02:46 PM
  4. Run time error 1004 only immediately after opening protected workbook
    By JoeSkittles in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2013, 11:02 AM
  5. Run time error 13, when VBA workbook opening in excel 2007
    By wkslee99 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-04-2013, 03:37 AM
  6. error code while opening a workbook
    By richardconers@yahoo.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-28-2005, 09:30 AM
  7. run code on opening workbook and apply code to certain sheets
    By Jane in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-08-2005, 05: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