Solved

VBA - Can't Unlist Table in Excel 2010

Posted on 2015-02-19
10
488 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 46

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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 46

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 46

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
 
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 46

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 46

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

791 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