Solved

VBA - Can't Unlist Table in Excel 2010

Posted on 2015-02-19
10
434 Views
Last Modified: 2016-02-10
Hi Experts,

I'm using ActiveSheet.ListObjects("myTABLE").Unlist to delete a Table but it gives me a Run-time error '9',  "Subscript out of range" error (even though I can visually see the Table name and location in the Name Manager dialog) but if I then try to add the same "myTable" Table with an .Add parameter, I get another Run-time error '1004' error saying "A table cannot overlap another table" (and there are no other Tables that overlap this Table's Rows/Columns).  

In the attached file, the calling sub that is causing the problem is "View_Room_Requirements_V1" and the actual Table name I'm trying to delete if it exists (and then subsequently add back) is: "TABLE_Room_Requirements".  I got around the original error by only trying to Unlist it IF it exists, but the subsequent Add still doesn't work because I can't delete the Table.

Hope this is clear.

Jeff
Master-Database-v-5.9--Re-Built----EE-Ex
0
Comment
Question by:jeffreywsmith
  • 5
  • 5
10 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40620112
You uploaded a file that has no code.
0
 
LVL 2

Author Comment

by:jeffreywsmith
ID: 40620158
Not sure what happened there, Martin, but I'll attach it again here.

Jeff
Master-Database-v-5.9--Re-Built----EE-Ex
0
 
LVL 2

Author Comment

by:jeffreywsmith
ID: 40620175
Huh. That one seems to have problems, too.  I notice the file name was changed from what I named it, too.  I will attach it zipped this time ...  Well, EE gives me an error when I try to upload the zipped version: "The archive could not be scanned: Stream closed".  Not sure what to do next ...

Jeff
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40620198
The table name isn't "TABLE_Room_Requirements" it's "TABLE_Room Requirements". No second underscore.
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40620203
BTW I believe the problem with us downloading the file is that you didn't include a valid Excel file extension.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 2

Author Comment

by:jeffreywsmith
ID: 40620422
Martin,

I'm not seeing where "TABLE_Room Requirements" with no second underscore is used.  The Range name uses both underscores and so do all instances of this Table in my code.  Can you advise where you are seeing this?

Also, I did include both the .xlsm and .zip extensions on the files I attempted to upload ... so can only assume a hiccup in the EE system ...
0
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40620457
If you add this code to module1 and run it

Sub ListListobjects()
Dim lngListObj As Long

With Sheets("2015 PCA FALL GRUPPENEINTEILUNG")
    For lngListObj = 1 To .ListObjects.Count
        Debug.Print "Listobject " & lngListObj & " is named " & .ListObjects(lngListObj).Name
    Next
End With
End Sub

Open in new window


This will be the output in the Immediate Window (Ctrl+g in the VBE)
No second underscore
0
 
LVL 2

Author Comment

by:jeffreywsmith
ID: 40620999
Well, that was strange.  Because I was able to see the Table named WITH the 2nd underscore in Name Manager.  But I did try unlisting the Table name withOUT the 2nd underscore in it, and it did delete.  

Thanks for the help with that, Martin.  Do you have any idea what could cause this and is it suggesting corruption in the file?

If so, I'd appreciate any suggestions on how to recover from same.

Jeff
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40621268
My guess is that it's some type of corruption because I don't believe that Excel normally allows a space in either a Table Name or in a Named Range. You might want to ask a new question and see if anyone has a solid explanation for the situation. If you do that could you please post the URL here because I'd be interested in following the discussion.

In any case you're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0
 
LVL 2

Author Comment

by:jeffreywsmith
ID: 40621296
Thanks, Marty.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

This article will show you how to use shortcut menus in the Access run-time environment.
My experience with Windows 10 over a one year period and suggestions for smooth operation
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now