If no list exists, exit sub

D

DoooWhat

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
 
O

Otto Moehrbach

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
 
D

DoooWhat

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top