Why does thiswork perfect in the immediate windowPlease Login or Register to view this content.
while this simple code does not work. Yes there are listobjects on the activesheet.Please Login or Register to view this content.
Why does thiswork perfect in the immediate windowPlease Login or Register to view this content.
while this simple code does not work. Yes there are listobjects on the activesheet.Please Login or Register to view this content.
<----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left
If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.
What error do you get?
Can you actually delete the ranges manually?
Deleting the ranges manually is a feature in excel so that works of course. Or what do you mean by manually? Like I mentioned it works fine in the immediate window.
Nevermind, I solved it I think. The "On Error Resume Next" statement was needed in case the databodyrange already was deleted, got an error if I tried to do it twice. Not the most proper way to do it but for this little snippet it works ok.
I tried to use an if statement to check the size of the databodyrange to determine if I could delete it but that causes another error.
I am using the name of the sheet (not the name on the tab, the object name) instead of activesheet for a more robust solution.
Please Login or Register to view this content.
Edit: I just saw this post, written by a certain mr Pope. It answers my question.
http://www.excelforum.com/excel-prog...=1#post3288648
Last edited by Jacc; 08-11-2013 at 08:15 AM.
Use either...
...or...Please Login or Register to view this content.
Please Login or Register to view this content.
Jacc
Instead of sticking a On Error Resume Next in the code, check if the DataBodyRange is nothing.
Please Login or Register to view this content.
If posting code please use code tags, see here.
Sorry jhren but these only work once. If I run it a second time I get error message. The reason apparently is that the object becomes nothing after being deleted, as Norie is pointing out. In my last post there was a link to an old post were Andy comes with the same answer.
Thanks for contributing, it works like a charm now.
@Jacc
I was in Reply mode when you made your last post (#3)... so didn't see it until after I posted, and Norie brought up the issue almost immediately thereafter... so I felt no need to amend.
As far as my post goes, your initial post gave no indication of any Table being empty (single blank row)... which is why you get an error when you run the second time. But as you have discovered, including the possibility in the code proves wise
Glad you got it sorted..!!!
Last edited by jhren; 08-11-2013 at 12:56 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks