LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default clearing non-numeric data

In regards to designing the function to completely
disregard thses cells until the function is finished
executing, how do I do this? Its obviously not a matter of
entering "cell.Ignore" ..... too bad. Help!

Eskima
P.S. You guys have been great so far!

-----Original Message-----
Tom

The Sum function in my UDF was just for an example, I

assume the actual
function is something that can't be done with worksheet

formulas.

Eskima

You need to design your function to handle cells that

don't contain the
correct data. In my example, if any cell doesn't contain

the correct type
of data, an error is returned. You could also design it

to ignore those
cells if that's what you want.

I didn't get from your original question that you wanted

the function to
clear cells, but if that is what you were asking, then

see Tom's response
i.e. you can't do it.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Tom Ogilvy" wrote in message
...
If you are putting this function in a worksheet as in

=AllNums2(A1:Z200)

then it will not clear any cells - because a function

used in a worksheet
can not change anything in the worksheet - it can only

return a value to
the
cell in which it is located (just like built in

functions).

Unless you have error values in your range, Sum(rng)

should work without
doing any clearing - sum ignores text and non-numeric

values (but not
errors
such as #N/A).

If you have errors, it would be easier to adjust your

formulas to not
return
errors

change
=formula
to

=if(iserror(formula),"",formula)

I have never seen sum have problems with an empty

string or a string that
is
not empty.

--
Regards,
Tom Ogilvy

"Eskima" wrote in message
...
My data sets are too large to do empty the cells

manually,
so I've tried making some changes to the function you

set
up, but it doesn't seem to do the clearing. You'll see
what I mean. Any more ideas?

Public Function AllNums2(Rng As Range) As Double

Dim cell As Range

For Each cell In Rng
If IsNumeric(cell.Value) = False Then
cell.ClearContents
End If
Next cell

AllNums2 = Application.Sum(Rng)

End Function


-----Original Message-----
Eskima

Are blanks OK, but nonnumerics not? You can loop

through
the cells and
check for nonnumerics and return an error if it finds
any. Here's and
example

Public Function AllNums(Rng As Range) As Double

Dim cell As Range

For Each cell In Rng.Cells
If Not IsNumeric(cell.Value) Then
AllNums = CVErr(2051)
Exit Function
End If
Next cell

AllNums = Application.Sum(Rng)

End Function

Blank cells will be treated as numeric because their
values will evaluate to
zero.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.


"Eskima" wrote in message
...
I have created a function (NoT a sub routine) in

Excel
that requires the cells in the range to contain

only
numeric data. Therefore, if there are any cells

that
contain letters, or even if a cell looks blank but
contains a space, the function does not work. Is

there a
way that I can get the function to cells containing
anything non-numeric in the given range BEFORE it

begins
its other calculations?


.





.

 
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
vba line for clearing data from a cell cvgairport Excel Discussion (Misc queries) 5 October 8th 09 01:06 PM
Clearing cells without clearing formulas marsjune68 Excel Discussion (Misc queries) 2 April 10th 09 07:39 PM
Clearing Data Troy2006 Excel Discussion (Misc queries) 3 October 31st 08 10:01 PM
Clearing unseen data Ralphael1 New Users to Excel 3 December 2nd 05 11:25 AM
VBA Question / Clearing out All Data carl Excel Worksheet Functions 3 March 2nd 05 07:57 PM


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