ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cells with null or no data (https://www.excelbanter.com/excel-programming/419998-cells-null-no-data.html)

Rpettis31

cells with null or no data
 
I have code that I have tried in various ways yet I can not get the code to
recognize a blank cell.
For z1 = 7 To 1300
If Cells(z1, 9) = "" Then Cells(z1, 10) = "HI"
If IsNull(Cells(z1, 9)) = True Then Cells(z1, 10) = "HI"
Next z1

I only used the word hi to stick out on the sheet.

Per Jessen

cells with null or no data
 
Are you sure the cells are empty. A cell may be "false empty" if it contains
a space character.

Try this:

For z1 = 7 To 1300
If Trim(Cells(z1, 9)) = "" Then Cells(z1, 10) = "HI"
If IsNull(Cells(z1, 9)) = True Then Cells(z1, 10) = "HI"
Next z1

Regards,
Per

"Rpettis31" skrev i meddelelsen
...
I have code that I have tried in various ways yet I can not get the code to
recognize a blank cell.
For z1 = 7 To 1300
If Cells(z1, 9) = "" Then Cells(z1, 10) = "HI"
If IsNull(Cells(z1, 9)) = True Then Cells(z1, 10) = "HI"
Next z1

I only used the word hi to stick out on the sheet.



Steve[_114_]

cells with null or no data
 
On Nov 13, 3:31*pm, Rpettis31
wrote:
I have code that I have tried in various ways yet I can not get the code to
recognize a blank cell.
* For z1 = 7 To 1300
* * * * If Cells(z1, 9) = "" Then Cells(z1, 10) = "HI"
* * * * If IsNull(Cells(z1, 9)) = True Then Cells(z1, 10) = "HI"
* * Next z1

I only used the word hi to stick out on the sheet.


Instead of using If Cells(z1, 9) = "", use If IsEmpty(Cells(Z1,9)).
This will truly check for an empty cell. Doing it the other way can
result in cells looking like they are blank but are filled with spaces.


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com