PC Review


Reply
Thread Tools Rate Thread

cells with null or no data

 
 
Rpettis31
Guest
Posts: n/a
 
      13th Nov 2008
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.
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      13th Nov 2008
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" <(E-Mail Removed)> skrev i meddelelsen
news:9D6830B1-FA77-4BBC-BE42-(E-Mail Removed)...
>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.


 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      13th Nov 2008
On Nov 13, 3:31*pm, Rpettis31 <Rpetti...@discussions.microsoft.com>
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.
 
Reply With Quote
 
John Bundy
Guest
Posts: n/a
 
      13th Nov 2008
Worked for me just by specifying which sheet to use
If Sheets(1).Cells(z1, 9) = "" Then Sheets(1).Cells(z1, 10) = "HI"
--
-John http://jmbundy.blogspot.com
Please rate when your question is answered to help us and others know what
is helpful.


"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.

 
Reply With Quote
 
Rpettis31
Guest
Posts: n/a
 
      14th Nov 2008
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.
"John Bundy" wrote:

> Worked for me just by specifying which sheet to use
> If Sheets(1).Cells(z1, 9) = "" Then Sheets(1).Cells(z1, 10) = "HI"
> --
> -John http://jmbundy.blogspot.com
> Please rate when your question is answered to help us and others know what
> is helpful.
>
>
> "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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
EXCEL Spreadsheet CELLS have data but load as NULL ITContractor Microsoft Excel Programming 4 11th Jan 2008 08:26 AM
null data not showing up if "is null" query criteria tcek Microsoft Access Queries 6 14th Dec 2007 06:28 PM
Show null and non null data =?Utf-8?B?U3RvY2t3ZWxsNDM=?= Microsoft Access Reports 0 24th Jul 2007 03:36 PM
Generating blank or null cells that the Histogram Data Analysis tool will ignore EddyKilowatt@gmail.com Microsoft Excel Worksheet Functions 2 12th Jun 2007 09:13 PM
Cells().value is null but I can see data JohnEnnever Microsoft Excel Programming 1 8th Jan 2004 02:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:03 AM.