+ Reply to Thread
Results 1 to 3 of 3

Checking whether a field is bold.

  1. #1
    Craig & Co.
    Guest

    Checking whether a field is bold.

    Hi,

    Looking for a command to do the following

    =IF (TEXT(A1) IS BOLD,<ADDITION FUNCTION>,<DIFFERENT FUNCTION>)

    Any ideas?

    Trying to put together a Line of Credit calculator, where my pay days are
    bolded, so
    to work out a pay day compared to an interest day I need the function to
    tell me if it's bold.

    I believe I have already worked out the function if both the interest day
    and pay day fall on the same day, just
    need to work out if the date is bold or not.

    Thank you in advance.
    Craig.



  2. #2
    Dave Peterson
    Guest

    Re: Checking whether a field is bold.

    You could use a UserDefined Function:

    Option Explicit
    Function isBold(rng As Range) As Variant

    application.volatile

    If rng(1).Font.Bold Then
    isBold = True
    ElseIf IsNull(rng(1).Font.Bold) Then
    isBold = "Mixed"
    Else
    isBold = False
    End If

    End Function

    Then you can use it in a worksheet cell like:
    =isbold(a1)

    or in your sample:
    =if(isbold(a1)=true,a1+a2,a1-a2)

    But be aware that changing the boldness of a cell is not something that causes
    excel to recalculate. Hit alt-ctrl-F9 to force it recalc (before you trust the
    results).

    If you're new to macros, you may want to read David McRitchie's intro at:
    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    Short course:

    Open your workbook.
    Hit alt-f11 to get to the VBE (where macros/UDF's live)
    hit ctrl-R to view the project explorer
    Find your workbook.
    should look like: VBAProject (yourfilename.xls)

    right click on the project name
    Insert, then Module
    You should see the code window pop up on the right hand side

    Paste the code in there.

    Now go back to excel.
    and type your formula into a test cell.

    "Craig & Co." wrote:
    >
    > Hi,
    >
    > Looking for a command to do the following
    >
    > =IF (TEXT(A1) IS BOLD,<ADDITION FUNCTION>,<DIFFERENT FUNCTION>)
    >
    > Any ideas?
    >
    > Trying to put together a Line of Credit calculator, where my pay days are
    > bolded, so
    > to work out a pay day compared to an interest day I need the function to
    > tell me if it's bold.
    >
    > I believe I have already worked out the function if both the interest day
    > and pay day fall on the same day, just
    > need to work out if the date is bold or not.
    >
    > Thank you in advance.
    > Craig.


    --

    Dave Peterson

  3. #3
    Craig & Co.
    Guest

    Re: Checking whether a field is bold.

    That's exactly what I needed.

    Will now use 'UserDefined' Functions for other things too.

    Thank you for this valuable insight into the workings of Excel.

    Cheers
    Craig.

    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > You could use a UserDefined Function:
    >
    > Option Explicit
    > Function isBold(rng As Range) As Variant
    >
    > application.volatile
    >
    > If rng(1).Font.Bold Then
    > isBold = True
    > ElseIf IsNull(rng(1).Font.Bold) Then
    > isBold = "Mixed"
    > Else
    > isBold = False
    > End If
    >
    > End Function
    >
    > Then you can use it in a worksheet cell like:
    > =isbold(a1)
    >
    > or in your sample:
    > =if(isbold(a1)=true,a1+a2,a1-a2)
    >
    > But be aware that changing the boldness of a cell is not something that

    causes
    > excel to recalculate. Hit alt-ctrl-F9 to force it recalc (before you

    trust the
    > results).
    >
    > If you're new to macros, you may want to read David McRitchie's intro at:
    > http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >
    > Short course:
    >
    > Open your workbook.
    > Hit alt-f11 to get to the VBE (where macros/UDF's live)
    > hit ctrl-R to view the project explorer
    > Find your workbook.
    > should look like: VBAProject (yourfilename.xls)
    >
    > right click on the project name
    > Insert, then Module
    > You should see the code window pop up on the right hand side
    >
    > Paste the code in there.
    >
    > Now go back to excel.
    > and type your formula into a test cell.
    >
    > "Craig & Co." wrote:
    > >
    > > Hi,
    > >
    > > Looking for a command to do the following
    > >
    > > =IF (TEXT(A1) IS BOLD,<ADDITION FUNCTION>,<DIFFERENT FUNCTION>)
    > >
    > > Any ideas?
    > >
    > > Trying to put together a Line of Credit calculator, where my pay days

    are
    > > bolded, so
    > > to work out a pay day compared to an interest day I need the function to
    > > tell me if it's bold.
    > >
    > > I believe I have already worked out the function if both the interest

    day
    > > and pay day fall on the same day, just
    > > need to work out if the date is bold or not.
    > >
    > > Thank you in advance.
    > > Craig.

    >
    > --
    >
    > Dave Peterson




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1