Can you use an if then statement to select bold values from a list?

D

Dave Peterson

One way is to use your own UserDefinedFunction that can check the formatting.

Option Explicit
Function IsBold(rng As Range) As Boolean

Application.Volatile

If IsNull(rng.Font.Bold) Then
IsBold = False
Else
IsBold = rng.Font.Bold
End If
End Function

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
Paste that code into the code window (usually on the righthand side)

Then back to excel:
Put something in A1. Bold (or don't) the font.
Put this in B1:
=isbold(a1)

Since formatting changes don't cause excel to recalculate, don't trust the
results of the formula until you've recalculated.

Then you can try:
=if(isbold(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