Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/





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
Failed to save table attributes of (null) into (null). Luca Brasi Excel Discussion (Misc queries) 2 February 4th 09 04:30 PM
setting a cell to 'empty' or blank or null ? KRK New Users to Excel 7 May 7th 08 12:49 AM
How do you stop excel from charting empty cells/null values as zer Abe-air Charts and Charting in Excel 3 March 20th 06 11:57 PM
make cell contents equal to null value - not blank, but empty mpierre Excel Worksheet Functions 1 December 29th 04 06:57 AM
testing for non-empty cells Paul James[_2_] Excel Programming 6 August 3rd 03 09:04 AM


All times are GMT +1. The time now is 02:22 PM.

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

About Us

"It's about Microsoft Excel"