Choose Font In A Formula

F

FARAZ QURESHI

Is there anyway to form a result in Wingdings if Yes, else in normal/standard
text.
For example I want the result to be reflecting the Checkmark Symbol (242) of
Wingdings if =A1=B1, else if =A1<>B1 the Cross Symbol (241) of Wingdings, and
finally in case of =OR(A1=0,B1=0) the result being in default Times New Roman
"Incomplete Data".

Your expert advice is sought and shall be obliged. Thanx in advance.
 
P

Pete_UK

A formula returns a result - it can't affect the font that is used in
the cell.

Hope this helps.

Pete
 
S

Stefi

Enter this formula in the result cell:
=IF(OR(A1=0,B1=0),"Incomplete Data",CHAR(IF(A1=B1,241,242)))

and install this event sub:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 1 And Target.Column <= 2 Then
Range("C1").Font.Name = _
IIf(Range("A1") = 0 Or Range("B1") = 0, "Times New Roman",
"Wingdings")
End If
End Sub

Regards,
Stefi


„FARAZ QURESHI†ezt írta:
 
S

Stefi

Check char codes for Checkmark Symbol and Cross Symbol! In my Excel 2003 241
and 242 are emmpty up and down arrows!
Stefi


„Stefi†ezt írta:
 
F

FARAZ QURESHI

I copied and pasted the code in the VBA module (Alt+F11) but upon pressing
F5/pushing the run button the empty macro box appears, and upon changing the
data in A1 or A2 doesn't execute the code. Any idea?
 
S

Stefi

You don't mention that the solution suits your needs or not!
Stefi


„FARAZ QURESHI†ezt írta:
 
G

Gord Dibben

1. Copy the code into the sheet module, not a general module.

2. The code runs upon an event, not manually.

3. Since you are running off a calculated cell use this instead.

Private Sub Worksheet_Calculate()
Range("C1").Font.Name = _
IIf(Range("A1") = 0 Or Range("B1") = 0, "Times New Roman", _
"Wingdings")
End Sub

Right-click on the sheet tab and "View Code". Copy/paste into that module.

Assumes the formula

=IF(OR(A1=0,B1=0),"Incomplete Data",CHAR(IF(A1<>B1,251,252)))

is entered in C1


Gord Dibben MS Excel MVP
 

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