Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default How to evaluate a blank field

I need to increment a number if the name field is blank but not if there is a
name already entered. The name field is defined as a 'general' field. I
thought I was on to something with a previous post regarding the IsNull
function (Thanks SusanV). However, it appears I'm getting a true result on
the IsNull test regardless of whether there is data in the field or not.

I've written the code as (D8 is the name field):

If IsNull(D8) Then
Code to increment the number and save goes here

But even when the name is blank (tested with a MsgBox) it's still not
performing the code.

Any help is greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to evaluate a blank field

Maybe...

if isempty(worksheets("Sheet99").range("D8")) then
...



Susan wrote:

I need to increment a number if the name field is blank but not if there is a
name already entered. The name field is defined as a 'general' field. I
thought I was on to something with a previous post regarding the IsNull
function (Thanks SusanV). However, it appears I'm getting a true result on
the IsNull test regardless of whether there is data in the field or not.

I've written the code as (D8 is the name field):

If IsNull(D8) Then
Code to increment the number and save goes here

But even when the name is blank (tested with a MsgBox) it's still not
performing the code.

Any help is greatly appreciated.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default How to evaluate a blank field

Thanks Dave but that doesn't work either. For some reason, even when the
field is empty I'm getting a false return on the isempty function....

"Dave Peterson" wrote:

Maybe...

if isempty(worksheets("Sheet99").range("D8")) then
...



Susan wrote:

I need to increment a number if the name field is blank but not if there is a
name already entered. The name field is defined as a 'general' field. I
thought I was on to something with a previous post regarding the IsNull
function (Thanks SusanV). However, it appears I'm getting a true result on
the IsNull test regardless of whether there is data in the field or not.

I've written the code as (D8 is the name field):

If IsNull(D8) Then
Code to increment the number and save goes here

But even when the name is blank (tested with a MsgBox) it's still not
performing the code.

Any help is greatly appreciated.


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to evaluate a blank field

Then the cell isn't really empty.

It could look empty for a few reasons:
1. The user hit the space bar instead of the delete key to "clear" the contents
of the cell.

2. You could have had a formula that evaluated to "" (=if(a1="","",a1) and then
converted to values.

Each of these leaves the cell non-empty.

maybe just looking at the .value would be sufficient:

if trim(worksheets("sheet99").range("d8").value) = "" then
.....



Susan wrote:

Thanks Dave but that doesn't work either. For some reason, even when the
field is empty I'm getting a false return on the isempty function....

"Dave Peterson" wrote:

Maybe...

if isempty(worksheets("Sheet99").range("D8")) then
...



Susan wrote:

I need to increment a number if the name field is blank but not if there is a
name already entered. The name field is defined as a 'general' field. I
thought I was on to something with a previous post regarding the IsNull
function (Thanks SusanV). However, it appears I'm getting a true result on
the IsNull test regardless of whether there is data in the field or not.

I've written the code as (D8 is the name field):

If IsNull(D8) Then
Code to increment the number and save goes here

But even when the name is blank (tested with a MsgBox) it's still not
performing the code.

Any help is greatly appreciated.


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to evaluate a blank field

You can test for an empty string or use the IsEmpty function.


Debug.Print Range("A1").Value = ""
Debug.Print IsEmpty(Range("A1"))



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Susan" wrote in message
...
I need to increment a number if the name field is blank but not
if there is a
name already entered. The name field is defined as a 'general'
field. I
thought I was on to something with a previous post regarding
the IsNull
function (Thanks SusanV). However, it appears I'm getting a
true result on
the IsNull test regardless of whether there is data in the
field or not.

I've written the code as (D8 is the name field):

If IsNull(D8) Then
Code to increment the number and save goes here

But even when the name is blank (tested with a MsgBox) it's
still not
performing the code.

Any help is greatly appreciated.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default How to evaluate a blank field

Thank you Dave and Chip. The Trim function worked great. Thanks again -
Happy New Year

"Chip Pearson" wrote:

You can test for an empty string or use the IsEmpty function.


Debug.Print Range("A1").Value = ""
Debug.Print IsEmpty(Range("A1"))



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Susan" wrote in message
...
I need to increment a number if the name field is blank but not
if there is a
name already entered. The name field is defined as a 'general'
field. I
thought I was on to something with a previous post regarding
the IsNull
function (Thanks SusanV). However, it appears I'm getting a
true result on
the IsNull test regardless of whether there is data in the
field or not.

I've written the code as (D8 is the name field):

If IsNull(D8) Then
Code to increment the number and save goes here

But even when the name is blank (tested with a MsgBox) it's
still not
performing the code.

Any help is greatly appreciated.




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
Linked date field in worksheet defaults a blank field as 1/0/1900 AmnNkD Excel Worksheet Functions 2 September 12th 06 05:42 PM
Returning a blank field pdgood Excel Worksheet Functions 2 March 1st 06 07:58 PM
how to have result field blank Ellen Excel Discussion (Misc queries) 2 December 13th 05 09:42 PM
checking for a blank field Oldjay[_2_] Excel Programming 19 December 10th 05 11:35 PM
Displaying blank field instead of #N/A Joe Hays Excel Discussion (Misc queries) 4 April 29th 05 01:26 AM


All times are GMT +1. The time now is 06:18 AM.

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"