![]() |
Testing for null or empty
Hello, I need to test a cell to see if it contains anything. If not
will delete its row. Sometimes the cell is "empty" and sometimes it i "null". Testing for both seems like too much. I will reuse this cod over and over. My question is, is there a way I can make each cell not containin info "null" or "empty" so I just have to test for one of them. M thought is to make a sub that will go through the sheet and make eac non-used cell "null". When I go to test later I can then just test fo each cell being null. Or if there is some simpler way to test for bot instead of isNull(cell1) or isEmpty(cell1). I could make my own su that does it, but I don't want to reinvent the wheel if one is ou there. Thanks -- Message posted from http://www.ExcelForum.com |
Testing for null or empty
Plea
"gwgeller " wrote in message ... Hello, I need to test a cell to see if it contains anything. If not I will delete its row. Sometimes the cell is "empty" and sometimes it is "null". Testing for both seems like too much. I will reuse this code over and over. My question is, is there a way I can make each cell not containing info "null" or "empty" so I just have to test for one of them. My thought is to make a sub that will go through the sheet and make each non-used cell "null". When I go to test later I can then just test for each cell being null. Or if there is some simpler way to test for both instead of isNull(cell1) or isEmpty(cell1). I could make my own sub that does it, but I don't want to reinvent the wheel if one is out there. Thanks. --- Message posted from http://www.ExcelForum.com/ |
Testing for null or empty
Please share with me how you would make the cell contain NULL and return
true for an IsNull Test (since you say you could change all blanks to NULL). for each cell in selection if Trim(cell.Text) = "" then cell.EntireRow.Delete End if Next -- Regards, Tom Ogilvy "gwgeller " wrote in message ... Hello, I need to test a cell to see if it contains anything. If not I will delete its row. Sometimes the cell is "empty" and sometimes it is "null". Testing for both seems like too much. I will reuse this code over and over. My question is, is there a way I can make each cell not containing info "null" or "empty" so I just have to test for one of them. My thought is to make a sub that will go through the sheet and make each non-used cell "null". When I go to test later I can then just test for each cell being null. Or if there is some simpler way to test for both instead of isNull(cell1) or isEmpty(cell1). I could make my own sub that does it, but I don't want to reinvent the wheel if one is out there. Thanks. --- Message posted from http://www.ExcelForum.com/ |
Testing for null or empty
That is what I was thinking of doing, I was hoping someone would know
-- Message posted from http://www.ExcelForum.com |
Testing for null or empty
I have only seen a few uses for isnull in Excel VBA and I can't recall a
situation where you can get a true response from IsNull from a cell (there could be a way, but unlikely you will encounter it. I don't think bringing in Null fields from an external database puts a Null in the field, but I can't say I have tested it.) Anyway, I showed you a way that should work. -- Regards, Tom Ogilvy "gwgeller " wrote in message ... That is what I was thinking of doing, I was hoping someone would know. --- Message posted from http://www.ExcelForum.com/ |
All times are GMT +1. The time now is 01:30 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com