LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default Zero-Length string vs Zero (also a valid value)

Hi all,

I was hoping for some advice - I've got Index function pulling data
and (as expected) in cases where the data-source cell is "", the Index
returns '0'. The point is that both "" and Zeros are valid values in
the data-source cells and what I'd need would be the cell, that
contains the Index would return exactly what's in the data-source
cells - if source= "", then would return "", if zero or anything else
- would return zero or anything else.
Currently I'm using the:
If(Index="","",index)
but because the 'Index' bit is actually quite a long statement, the
function is just way too long for my liking and i was hoping there was
a smarter way of achieving the same result. The Tools-options-zero or
Cell formatting doesn't work as it hides also the valid zeros...

What seem to work is UDF:

Public Function nonzero(myLookup)
If myLookup = vbNullString Then
nonzero = vbNullString
Else
nonzero = myLookup
End If
End Function

And then in the cell I'd have =nonzero(index). But, (1) i don't know
if the code i've written is correct (i.e., if "vbnullstring" is the
constant i should be using); (2) it requires users to enable macros as
otherwise the function wouldn't work.

So, all in all, i was hoping that there was a bit more elegant/
accurate solution than the above and perhaps using just .xls default
functions (i.e., avoiding UDF/xla etc.).

Any ideas appreciated!
 
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
Finding a string of unknown length in a string of unknown length, Help! Hankjam[_2_] Excel Discussion (Misc queries) 8 July 3rd 08 06:49 PM
Finding cells of different string length. kingie Excel Discussion (Misc queries) 5 March 13th 08 12:31 AM
String length jxbeeman Excel Discussion (Misc queries) 1 January 10th 08 07:01 PM
Word could not parse your query options into a valid sql string Lizzzzzzzz Excel Discussion (Misc queries) 4 April 24th 06 12:08 PM
Valid SQL string Malcolm Agingwell Excel Discussion (Misc queries) 0 August 12th 05 11:00 AM


All times are GMT +1. The time now is 04:20 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"