Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old December 15th 05, 08:14 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Nov 2005
Posts: 175
Default If statement not working

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


  #2   Report Post  
Old December 15th 05, 08:22 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Nov 2003
Posts: 11,272
Default If statement not working

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)


"excelnut1954" wrote in message
ups.com...
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



  #3   Report Post  
Old December 15th 05, 08:55 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Nov 2005
Posts: 175
Default If statement not working

"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

  #4   Report Post  
Old December 15th 05, 08:58 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Nov 2003
Posts: 11,272
Default If statement not working

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)


"excelnut1954" wrote in message
ups.com...
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



  #5   Report Post  
Old December 15th 05, 09:21 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Nov 2005
Posts: 175
Default If statement not working

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.



  #6   Report Post  
Old December 15th 05, 10:22 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Jul 2006
Posts: 4,339
Default If statement not working

I have emulated your code and it works OK for me.

"excelnut1954" wrote:

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.


  #7   Report Post  
Old December 15th 05, 10:38 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Nov 2005
Posts: 175
Default If statement not working

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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statement not working Barrett M Excel Worksheet Functions 8 May 6th 08 03:29 PM
If statement working only once Lime Excel Worksheet Functions 0 May 5th 08 03:58 AM
If Statement Not Working Telegirl Excel Worksheet Functions 9 May 12th 07 04:34 PM
IF statement not working TJAC Excel Discussion (Misc queries) 2 January 13th 06 02:08 PM
If statement not working right TimT Excel Programming 2 July 11th 05 06:18 PM


All times are GMT +1. The time now is 12:20 AM.

Powered by vBulletin® Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright 2004-2021 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"

 

Copyright © 2017