Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Clifford Chapman   on Feb 07 In MS Office Category.

  
Question Answered By: Luise Fischer   on Feb 07

If you add 3 to a typed-in numerical rating, you risk losing the original
value (which will certainly happen) and also risk having the 3 added more
than once, or not removed properly if you got the original bolding wrong.

My preferred solution to this sort of thing is to:

(1) Put the adjustment in a calculated field - in this case, that's
presumably column E.

(2) Write a small VBA function that will return True if the font is bold.
Then do the rest in the formula.

So, the function is

Option Explicit

Public Function IsBold(ByRef Cell As Range) As Boolean
Call Application.Volatile
IsBold = Cell.Font.Bold
End Function

In its essentials, this simply returns True or False depending on whether
the font in the range passed to it is bold or not.

However, note that the act of bolding/unbolding a cell does not actually
result in the recalculation of anything. I have inserted the Volatile call
to ensure that the cell containing the function call will be recalculated
every time anything else is recalculated. This is not, of itself, enough to
get you a recalculation, but at least an F9 will now cause the calculation
to be redone.

How to use it?

Your basic formula for E38 is

=B38-D38

Now, exactly one of A38 or C38 will be bold, to indicate which is the home
team. (My assumption is that there is always a home team.) Therefore, you
can assume the underdog is the home team if the favourite is not bold.

=B38-D38+IF(IsBold(A38),3,-3)

So add 3 if the favourite is the home team and subtract 3 if it is not.

If neutral games are possible, then

=B38-D38+IsBold(A38)*3-IsBold(C38)*3

relies on the fact that True can be used as 1 and False as 0 in a numeric
calculation.

Share: 

 

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

 
Didn't find what you were looking for? Find more on Help for a (Hypothetical) Gambler! Or get search suggestion and latest updates.


Tagged: