My Assistant
![]() ![]() |
|
|
Jun 20 2007, 06:36 AM
Post
#1
|
|
|
UtterAccess Veteran Posts: 373 From: England |
Hi Wondering if someone could shed some light on why the following formulae inserted into a cell is unable to distinguish between a blank cell and a filled in cell.
The cell its refrencing comes from a worksheet that is pasted in to the worksheet it references. If I type in a value in the blank cell then delete it making it blank it then works ? Is this a bug ??? Anything else appers to work ie =IF(B2 = "%",0,1) Thanks, Jim. |
|
|
|
Jun 20 2007, 06:48 AM
Post
#2
|
|
|
UtterAccess Editor Posts: 15,974 From: Northern Virginia, USA |
I don't have an explanation at the moment, but a lot of times I use something like this:
=IF(LEN(TRIM(B2))=0,0,1) |
|
|
|
Jun 20 2007, 07:50 AM
Post
#3
|
|
|
UtterAccess VIP Posts: 6,171 From: Bethesda, MD USA |
I entered in the following and it works fine:
=IF(A1="",0,1) |
|
|
|
Jun 20 2007, 08:43 AM
Post
#4
|
|
|
UtterAccess Veteran Posts: 373 From: England |
STAR !!
Maybe the gurus could shed a light on this, Thanks anyway, Jim. |
|
|
|
Jun 20 2007, 08:53 AM
Post
#5
|
|
|
UtterAccess Editor Posts: 15,974 From: Northern Virginia, USA |
Glad one of our solutions worked!! .... (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif)
... Quick note ... the reason I did the Len(Trim(A1)) route is that I have been "burnt" before with people entering in a bunch of spaces to "Delete" a value in a cell, so I use the Trim to take care of that problem. Your comment ... >> Maybe the gurus could shed a light on this. << What is the exact formula you used? .... it is unclear from your post if you used something different than the formula in your initial post (which, by the way, does not look for blank cells.) Edited by: datAdrenaline on Wed Jun 20 10:03:08 EDT 2007. |
|
|
|
Jun 20 2007, 10:18 AM
Post
#6
|
|
|
UtterAccess VIP Posts: 2,601 From: Dallas, Texas USA |
There is no crazy explanation for this. The cell is actually not blank. If there is a space, line feed character, HTML non-breaking space, or other non-printable character present within the cell, the ISBLANK formula will return false. Try a LEN function on the cell that you think is blank. I would bet that it returns a value greater than zero.
In the case of the non-printable characters the TRIM method, or just testing for a null string (""), typically will not work. This is usually a symptom copying and pasting from a web page, and can be very frustrating since they are not visible characters. In those cases you would need to "remove" the characters from the cell using a string function or via Find\Replace. HTH, |
|
|
|
Jun 20 2007, 10:55 AM
Post
#7
|
|
|
UtterAccess Editor Posts: 15,974 From: Northern Virginia, USA |
... Woops ... I guess the "Exact Function" I asked for was right in the subject .... DOH!!! ... I even read it!! ... how bad is that! ...
.... I would think the CLEAN() function would get rid of the extra stuff... |
|
|
|
Jun 20 2007, 11:31 AM
Post
#8
|
|
|
UtterAccess VIP Posts: 2,601 From: Dallas, Texas USA |
QUOTE I would think the CLEAN() function would get rid of the extra stuff... You would think wouldn't you since that is what the function description says. However, try this out: =LEN(CLEAN("1111"&CHAR(160))) Returns 5 instead of 4. |
|
|
|
Jun 20 2007, 11:56 AM
Post
#9
|
|
|
Retired Moderator Posts: 10,959 From: Prague,CZ / Kiev,UA |
Hello,
I am afraid CLEAN() won't eliminate the CHAR(160) ascii character (?): QUOTE The CLEAN function was designed to remove the first 32 nonprinting characters in the 7-bit ASCII code (values 0 through 31) from text. In the Unicode character set (Unicode: A character encoding standard developed by the Unicode Consortium. By using more than one byte to represent each character, Unicode enables almost all of the written languages in the world to be represented by using a single character set.), there are additional nonprinting characters (values 127, 129, 141, 143, 144, and 157). By itself, the CLEAN function does not remove these additional nonprinting characters =LEN(CLEAN("1111"&CHAR(31))) works as expected. Martin |
|
|
|
Jun 20 2007, 12:06 PM
Post
#10
|
|
|
UtterAccess Editor Posts: 15,974 From: Northern Virginia, USA |
I am an Access guy by nature .... so I have created the following procedures to help with my text cleaning tasks, they should work fine in Excel too ...
CODE Public Function RemSpecial(strText As String, ParamArray strExeptions()) As String 'Removes special characters from a string. (Space is considered "Special") 'Usage: 'RemSpecial("My // text here") --> Yeilds: "Mytexthere" 'RemSpecial("My // text here", " ") --> Yeilds: "My text here" 'RemSpecial("My //\\ text here","\", " ") --> Yeilds: "My \\ text here" Dim x As Integer Dim Y As Integer Dim strX As String Dim strStrippedText As String 'Ascii codes Const conNumberRangeStart = 48 Const conNumberRangeStop = 57 Const conCapLettersStart = 65 Const conCapLettersStop = 90 Const conSmallLettersStart = 97 Const conSmallLettersStop = 122 'Loop through each digit of the string to determine if it falls into the 'Ascii ranges OR is an exception For x = 1 To Len(strText) strX = Mid(strText, x, 1) Select Case Asc(strX) Case conNumberRangeStart To conNumberRangeStop, _ conCapLettersStart To conCapLettersStop, _ conSmallLettersStart To conSmallLettersStop strStrippedText = strStrippedText & strX Case Else For Y = 0 To UBound(strExeptions()) If strX = strExeptions(Y) Then strStrippedText = strStrippedText & strX End If Next Y End Select Next x RemSpecial = strStrippedText End Function And this one .... CODE Public Function RemCode(strText, ParamArray intAsciiCodes()) As String 'Removes ascii codes from a string. Typical use is to remove 10 (carriage return) & 13 (line feed) 'Usage: 'RemCode("My text <cr><lf>is here",10,13) --> Yeilds: "My text is here" 'RemCode("My text is here", Asc("t")) --> Yeilds: "My ex is here" Dim y As Integer 'Start with the string strText = Nz(Trim(strText)) 'Replace the Ascii Codes passed with a ZLS For y = 0 To UBound(intAsciiCodes()) strText = Replace(strText, Chr(intAsciiCodes(y)), "") Next y 'Return the result RemCode = strText End Function |
|
|
|
Jun 20 2007, 12:19 PM
Post
#11
|
|
|
Retired Moderator Posts: 10,959 From: Prague,CZ / Kiev,UA |
This is nice... (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif)
You know me Brent, I'd be tempted to loop through a byte array, byte after byte, but I admit that this is simple and elegant (IMG:http://www.utteraccess.com/forum/style_emoticons/default/sad.gif) Martin |
|
|
|
Jun 20 2007, 12:45 PM
Post
#12
|
|
|
UtterAccess VIP Posts: 2,601 From: Dallas, Texas USA |
QUOTE works as expected. I agree Martin, that was what I was trying to show. What I was referring to was the description of the function in the help file (mabye that was what you were quoting, I think you have v.11) and the Paste Function Dialog. From the 2000 help file: QUOTE Removes all nonprintable characters from text. Use CLEAN on text imported from other applications that contains characters that may not print with your operating system. For example, you can use CLEAN to remove some low-level computer code that is frequently at the beginning and end of data files and cannot be printed. And from the Paste Function Dialog... QUOTE Removes all nonprintable characters from text. I find it quite misleading. |
|
|
|
Jun 20 2007, 01:03 PM
Post
#13
|
|
|
UtterAccess Editor Posts: 15,974 From: Northern Virginia, USA |
... Oh yes! ... I thought of that (you and byte arrays) too ... the code I pasted in this thread was just above the ScrambleWords() code from "back in the day" ... that was a fun one!
|
|
|
|
Jun 20 2007, 02:11 PM
Post
#14
|
|
|
Retired Moderator Posts: 10,959 From: Prague,CZ / Kiev,UA |
That's right Eric, I quoted from XL11 Help file, and yep, I find the comment as well as the WF itself quite misleading...
I personally wouldn't rely on it in a serious VBA code but it may very well be just a matter of my taste (IMG:http://www.utteraccess.com/forum/style_emoticons/default/sad.gif) Martin |
|
|
|
Jun 20 2007, 02:14 PM
Post
#15
|
|
|
Retired Moderator Posts: 10,959 From: Prague,CZ / Kiev,UA |
Brent, hey, you've got memory like an elephant, as we here like to say (IMG:http://www.utteraccess.com/forum/style_emoticons/default/sad.gif)
I was beaten but I got a kick out of that thread as well... nice exercise (IMG:http://www.utteraccess.com/forum/style_emoticons/default/compute.gif) Have a nice day M. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 24th May 2013 - 09:39 AM |