Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF Statement not working | Excel Worksheet Functions | |||
If statement working only once | Excel Worksheet Functions | |||
If Statement Not Working | Excel Worksheet Functions | |||
IF statement not working | Excel Discussion (Misc queries) | |||
If statement not working right | Excel Programming |