cells with null or no data

  • Thread starter Thread starter Rpettis31
  • Start date Start date
R

Rpettis31

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.
 
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
 
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.
 
Worked for me just by specifying which sheet to use
If Sheets(1).Cells(z1, 9) = "" Then Sheets(1).Cells(z1, 10) = "HI"
 
I discovered that I had used the wrong value "x" instead of Z in my code.
If Sheets(1).Cells(z1, 9) = "" Then Sheets(1).Cells(x1, 10) = "HI"

THanks all.
 
Back
Top