Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-08-2014, 06:01 AM
NobodysPerfect NobodysPerfect is offline Using fields to test on empty ? Windows 8 Using fields to test on empty ? Office 2010 32bit
Competent Performer
Using fields to test on empty ?
 
Join Date: Jan 2014
Location: Germany
Posts: 136
NobodysPerfect is on a distinguished road
Default Using fields to test on empty ?

Hi to all

I'm looking for a non VBA solution (macros not allowed) for the following problem:

Given: table with 3 columns. In columns A and B values can be entered but need not. Possible values in A and B: positive, negative, decimals and zero). The result of the calculation in column C is =(b1-a1) \# "+0,00;-0,00;0,00.

Challenge: The result must not be displayed if one (or both) of the cells A1 or B1 is empty. So I tried:

{ IF { = AND ( { = ABS(b1) } > 0 , { = ABS(a1) } > 0) } = 1 "{ =(b1-a1) \# "+0,00;-0,00;0,00 }" }


Works fine unless A1 and B1 are zero ("0") because then AND will be false. So I tried some calculation and set the condition to ">= 0" expecting empty fields would throw some error:



{ IF { = AND ( { = ABS(b1*1) } >= 0 , { = ABS(a1*1) } >= 0) } = 1 "{ =(b1-a1) \# "+0,00;-0,00;0,00 }" }


Unfortunately, Word does calculate with empty fields, it simply assumes "0". So there are equal results with empty cells and cells containing "0".

Do you see any chance to test cells on empty (or not numeric) just using fields? I don't.

Thanks for any help
NP

Last edited by NobodysPerfect; 10-08-2014 at 09:02 AM.
Reply With Quote
  #2  
Old 10-09-2014, 03:02 AM
macropod's Avatar
macropod macropod is offline Using fields to test on empty ? Windows 7 64bit Using fields to test on empty ? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,343
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

A word formula using a cell reference cannot differentiate between 0 and empty. However, it can be done if the ranges are bookmarked and you test the bookmark contents. The easiest way to do that is to use formfields for the data entry in a document using forms protection. That also gives you the advantage of being able to use the formfields' 'calculate on exit' property to auto-update the calculations.

In a generalised sense, the calculation field to evaluate the content is:
{IF{REF MyFld} = {=MyFld} "{MyFld} is Numeric" "{MyFld} is Text"}}
where 'MyFld' is the formfield's internal bookmark name.

Thus, for your purposes, the field might be coded as:
{IF{REF Text1} = {=Text1} {IF{REF Text2} = {=Text2} {={Text1}-{=Text2} \# "+0,00;-0,00;0,00"}}}
where 'Text1' & 'Text2' are the formfields' internal bookmark names.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-09-2014, 04:29 AM
NobodysPerfect NobodysPerfect is offline Using fields to test on empty ? Windows 8 Using fields to test on empty ? Office 2010 32bit
Competent Performer
Using fields to test on empty ?
 
Join Date: Jan 2014
Location: Germany
Posts: 136
NobodysPerfect is on a distinguished road
Default

Hi,

What a great solution .

Thanks, Paul

NP
Reply With Quote
  #4  
Old 10-11-2014, 02:19 AM
NobodysPerfect NobodysPerfect is offline Using fields to test on empty ? Windows 8 Using fields to test on empty ? Office 2010 32bit
Competent Performer
Using fields to test on empty ?
 
Join Date: Jan 2014
Location: Germany
Posts: 136
NobodysPerfect is on a distinguished road
Default

Sorry for re-opening this thread, but ...

... to work with negative values the {REF Text1} = {=Text1} part has to be formatted the same way, the FormField is formatted: e.g. {REF Text1} = {=Text1 \# "0,00"}. Otherwise IF will return FALSE.

That's at least what I experienced. Now each value is accepted and calculated the way it should be.

Cheers
NP
Reply With Quote
  #5  
Old 10-11-2014, 03:01 AM
macropod's Avatar
macropod macropod is offline Using fields to test on empty ? Windows 7 64bit Using fields to test on empty ? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,343
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

True, if you have a formatted number, the switch on the right side of the test needs to mirror that.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
test Cheekychino PowerPoint 1 04-08-2013 09:09 PM
Using fields to test on empty ? Write Test dkub Word VBA 1 07-21-2012 09:01 PM
Apparently empty (blank) cells aren't empty daymaker Excel 3 03-08-2012 03:41 PM
Using fields to test on empty ? Vba, Is there a better way to test empty cells? Hwyn Excel Programming 2 11-14-2011 11:44 AM
Test after presentation? barnkat PowerPoint 0 08-13-2010 10:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft