Solved

VBA - Can't Unlist Table in Excel 2010

Posted on 2015-02-19
10
573 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 48

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 48

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 48

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 48

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 48

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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
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…

623 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