Excel 2007 and IF formulas

P

pgarcia

Is there an IF formula in 2007 that if a cell to the right or left is BOLD
then it will BOLD that cell?

Thanks
 
D

Dave Peterson

If that other cell is bolded by formatting (not conditional formatting), then
you could use userdefined function.

Option Explicit
Function IsBold(rng As Range) As Boolean
Application.Volatile

Dim ChkBold As Variant

Set rng = rng.Cells(1)
ChkBold = rng.Font.Bold

IsBold = False
If ChkBold = True Then
IsBold = True
End If

End Function

And changing the format of the cell won't change the results of this formula.
You'll have to force a recalc before you can trust the results.

If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

========
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.
Into a test cell and type:
=IsBold(a1)
Where A1 contains the value to check.

===========
Now you can use this UDF in your Conditional formatting formula is rule:

=isbold(a1)
(if you're checking A1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top