![]() |
If no list exists, exit sub
I need help with the syntax on a conditional statement in a macro.
The macro works perfectly if a list (filtered list) exists. However, if no lists exist on the page, I get an error message. I want to start my code with a condition that does the following: If no list exists Exit sub Else ........... I can take it from there. Any help would be very much appreciated. Kevin |
If no list exists, exit sub
Kevin
It's going to be up to you to decide what constitutes "no list". Something like "there's no entries in range such and such", or if there is no entry in this cell or that cell or whatever. For instance, let's say the list would be in A1:A10 if there is a list. The following line of code would exit the sub if nothing is in that range. If Application.CountA(Range("A1:A10")) = 0 Then Exit Sub HTH Otto "DoooWhat" wrote in message oups.com... I need help with the syntax on a conditional statement in a macro. The macro works perfectly if a list (filtered list) exists. However, if no lists exist on the page, I get an error message. I want to start my code with a condition that does the following: If no list exists Exit sub Else .......... I can take it from there. Any help would be very much appreciated. Kevin |
If no list exists, exit sub
Sorry, I guess my initial inquiry was a little ambiguous. Let's
assume that there is ALWAYS data in the target range. When I refer to a list, I am talking about when you highlight a range, then go to Data \List\Create List. Kevin |
All times are GMT +1. The time now is 02:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com