Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Oscar Montgomery   on Nov 17 In MS Office Category.

  
Question Answered By: Alfonsine Miller   on Nov 17

What kind of error do you get?
Since you're using string functions  and then applying numeric tests
it begins to get confusing.
It looks (from the name of the function  and the code) as though
you're trying to round to the nearest 25p? (Hope I'm not meddling
here)

To do this with numbers use:

Function Round25(money)
Round25 = Round(money * 4, 0) / 4
End Function

It may not be worth having a function at all, try
=ROUND(A1 * 4, 0) / 4
in a cell.

You may have to format the cells as money to make it look right, also
it rounds 12p down and 13p up, whereas you round 12 up, and similar
at other boundaries; this could easily be adjusted.

If the original data is text you could just strip the £ sign off
and
use numbers to convert then add the £ sign back on (or format the
result as money).

BTW, a bunch of If.. ..then ..else.. end ifs is quite difficult to
fathom when writing macros, have a look at the 'Select Case'
statement.

Is the data you're working on text or values?
In what form do you want the result?

Share: 

 

This Question has 6 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on user defined functions Or get search suggestion and latest updates.


Tagged: