Article View: comp.apps.spreadsheets
Article #266Re: Excel Font Question
From: Joel Spolsky
Date: Tue, 17 Nov 1992 01:21
Date: Tue, 17 Nov 1992 01:21
43 lines
1908 bytes
1908 bytes
In article <BxoC2K.8v3@da_vinci.it.uswc.uswest.com> rmcinty@venezia.it.uswc.uswest.com (Robert P. McIntyre) writes:
>I need some help with an Excel question. Is it possible to interactively
>test a cell or range of cells and adjust the font (e.g. bold, italic,
>etc.) based on the result of the test?
There are several approaches to accomplish what you want.
The easiest way is to change the color of the cell by using a
conditional format. For example, if you set the number format of a cell
to
[>1000] [BLUE]0; [<-1000] [RED]0; [GREEN]0
the cell will be blue if it is greater than 1000, red if it is less
than -1000, and green otherwise. For more information on conditional
formats, see p.224 in User's Guide 1. Unfortunately, conditional formats
can only include colors, not other font attributes like bold or italic.
A more general solution would be to write a macro which scans the
appropriate cells and changes their formats, based on their values. As
a simple example, the following macro scans the cells from A1 to A10
and makes all the negative cells bold:
A
1 NegBold
2 =FOR.CELL("cel","r1c1:r10c1")
3 = SELECT(REFTEXT(cel))
4 = ACTIVE.CELL()
5 = IF(A4<0)
6 = FORMAT.FONT(,,TRUE)
7 = END.IF()
8 = NEXT()
9 =RETURN()
You can attach this to a menu, a keyboard accelerator, or a button on
the worksheet, or you can use the ON.ENTRY function to have this macro
run automatically every time you change the worksheet.
--
Joel Spolsky
Program Manager
Microsoft Excel
joelsp@microsoft.com
Technical Details
Message-ID:
<1992Nov17.012142.19249@microsoft.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!joelspReferences:
<BxoC2K.8v3@da_vinci.it.uswc.uswest.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.apps.spreadsheets Path: arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!joelsp From: joelsp@microsoft.com (Joel Spolsky) Subject: Re: Excel Font Question Message-ID: <1992Nov17.012142.19249@microsoft.com> Date: 17 Nov 92 01:21:42 GMT Organization: Microsoft Corporation References: <BxoC2K.8v3@da_vinci.it.uswc.uswest.com> Lines: 45