![]() |
Still having problem with IF-Then statement
I hate to keep taking up space for this, but it just won't work for me.
I've tried to work around it from a differnt angle, but damn, this should work! And, it seems it should be so simple. I really appreciate the reponses I've gotten on this problem. It's very frustrating. Here's the solution given to me before.... and I'm sure it's a good one. But, why doesn't it work for me? 'If Range("Deleted_Today") = 0 Then ' FormatCells ' Else ' Move_Deleted_Records ' End If I want it to look at the range name "Deleted_Today". This is in a worksheet named Touches. It contains a formula that counts any entries in a column in a different worksheet, named Official List. Here's that formula: =COUNTA('Official List'!P6:P4366) If there are any entries in that column, the number will be more than 0 in "Deleted_Today". If that is the case, I want the macro to go to the sub named FormatCells. If there is anything greater than 0 in "Deleted_Today", then it want it to go the sub named Move_Deleted_Records. However there is an error when I run it, and the 1st line of the statement is hightlighted. I've checked all the spellings. Should I specify the worksheets? I was given this statement as an alternative, but I get the same results. If Application.CountA(Range("Deleted_Today")) = 0 Then ' FormatCells ' Else ' Move_Deleted_Records ' End If Does it matter if there is a formula in that cell, or if it just a value? I even tried to replace the formula in "Deleted_Today" with a 0. Same error. No sense in programming if you can't do a simple If-then. My spreadsheet designs are full of If-then formulas. It's the basic tool of spreadsheets design for me. Bob Phillips, you have given me alot of time, and have been very patient. If you, or anyone else can figure out what stupid mistake I'm making, I would greatly appreciate it. Thanks HELP!! |
Still having problem with IF-Then statement
Try one of the following:
If Sheeets("Touches").Range("Deleted_Today").Value = 0 Then FormatCells Else Move_Deleted_Records End If OR If Application.WorksheetFunction.CountA(Range("Delete d_Today")) = 0 Then FormatCells Else Move_Deleted_Records End If "excelnut1954" wrote: I hate to keep taking up space for this, but it just won't work for me. I've tried to work around it from a differnt angle, but damn, this should work! And, it seems it should be so simple. I really appreciate the reponses I've gotten on this problem. It's very frustrating. Here's the solution given to me before.... and I'm sure it's a good one. But, why doesn't it work for me? 'If Range("Deleted_Today") = 0 Then ' FormatCells ' Else ' Move_Deleted_Records ' End If I want it to look at the range name "Deleted_Today". This is in a worksheet named Touches. It contains a formula that counts any entries in a column in a different worksheet, named Official List. Here's that formula: =COUNTA('Official List'!P6:P4366) If there are any entries in that column, the number will be more than 0 in "Deleted_Today". If that is the case, I want the macro to go to the sub named FormatCells. If there is anything greater than 0 in "Deleted_Today", then it want it to go the sub named Move_Deleted_Records. However there is an error when I run it, and the 1st line of the statement is hightlighted. I've checked all the spellings. Should I specify the worksheets? I was given this statement as an alternative, but I get the same results. If Application.CountA(Range("Deleted_Today")) = 0 Then ' FormatCells ' Else ' Move_Deleted_Records ' End If Does it matter if there is a formula in that cell, or if it just a value? I even tried to replace the formula in "Deleted_Today" with a 0. Same error. No sense in programming if you can't do a simple If-then. My spreadsheet designs are full of If-then formulas. It's the basic tool of spreadsheets design for me. Bob Phillips, you have given me alot of time, and have been very patient. If you, or anyone else can figure out what stupid mistake I'm making, I would greatly appreciate it. Thanks HELP!! |
Still having problem with IF-Then statement
Hello Excelnut1954, Change this line: If Application.CountA(Range("Deleted_Today")) = 0 Then To: If WorksheetFunction.CountA(Range("Deleted_Today")) = 0 Then This should fix the problem provided Deleted_Today is a named Range. If not you will have to add the worksheet also. Just change Sheet1 to the name of the sheet the range is on. Alternate: If WorksheetFunction.CountA(Worksheets("Sheet1").Rang e(("Deleted_Today")) = 0 Then Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=494374 |
Still having problem with IF-Then statement
Looks like the 1st option was successful. I was thinking of adding the
sheet name, but I didn't know the proper syntax. I just don't know enought yet to explain why the other options given to me didn't work. I probably just didn't explain the layout well enough. If that's the case, then thanks for reading my mind to find out what I was after. Thanks Cush. Thankyou Bob Phillips & Leith Ross for your contributions. I save them all for future reference. I hope to learn this well enough to be able to contribute, and help someone like you guys do. Thanks again. |
All times are GMT +1. The time now is 04:53 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com