ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel 2007 and IF formulas (https://www.excelbanter.com/excel-discussion-misc-queries/220845-excel-2007-if-formulas.html)

pgarcia

Excel 2007 and IF formulas
 
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

Dave Peterson

Excel 2007 and IF formulas
 
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 he
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)

pgarcia wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 11:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com