Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Linked date field in worksheet defaults a blank field as 1/0/1900 | Excel Worksheet Functions | |||
Returning a blank field | Excel Worksheet Functions | |||
how to have result field blank | Excel Discussion (Misc queries) | |||
checking for a blank field | Excel Programming | |||
Displaying blank field instead of #N/A | Excel Discussion (Misc queries) |