If statement not working

E

excelnut1954

On Nov 23, I got a respons on how to construct an IF statement to
redirect the flow of a macro. I was given the coding to solve the
problem. I wasn't able to continue with the project until today. I've
changed it a little from what I was given here because of the creation
of 2 new subs I wanted to include in the flow of control. But, I'm
having a problem with it.

The macro is suppose to check the range "Deleted_Today". If it is 0,
then I wanted to redirect to a sub named FormatCells. If there was a
number in there, then it would go to a sub named Move_Deleted_Records.

As always, I appreciate all the responses I've gotten here. However, I
get an error, and it highlights the 1st line. I've check to make sure
the spelling of the range name, and the 2 subs are correct. Can someone
help explain why this is hanging up?
Thanks,


If Range("Deleted_Today") = 0 Then
FormatCells
Else
Move_Deleted_Records
End If
 
B

Bob Phillips

What is Deleted_Today? Is it a range name in Excel, or is it a VBA variable?
If as I suspect it is the latter, is it a string or a range? What did you
initialise it to?

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
E

excelnut1954

"Deleted_Today" is just a cell range name. It has a formula in it to
count the number of entries in a column. If there are no entries in
that column, then I want the macro to to directly to the FormatCells
sub. Otherwise, if there are entries in that column, then I want it to
go to the sub Move_Deleted_Records.
I guess I wasn't clear enough about this. Hope I cleared it up.

Thanks Bob
 
B

Bob Phillips

Try

If Application.COUNTA(Range("Deleted_Today")) = 0 Then
FormatCells
Else
Move_Deleted_Records
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
E

excelnut1954

No. Still getting the 1st line highlighted.
Here's the formula in the range "Deleted_Today"
=COUNTA('Official List'!P6:p4366)
Official List is the name of the worksheet it is looking at for the
entries in column P.
The "Deleted_Today" range is in the worksheet named Touches.

Trying to give you as much as I can.
Thanks for helping me.
 
E

excelnut1954

Everyone...
I really appreciate your time/help. I sent the file home, and will look
at it again tonight. Obviously I got something wrong. I'll look at it
tonight at home, where I won't be bothered by all the other stuff here
at work. I prefer programming at home..... nice and quiet.
 

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