If no list exists, exit sub

  • Thread starter Thread starter DoooWhat
  • Start date Start date
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
 
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
 
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
 
Back
Top