home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / apps / spreadsh / 659 < prev    next >
Encoding:
Text File  |  1992-11-17  |  1.8 KB  |  56 lines

  1. Newsgroups: comp.apps.spreadsheets
  2. Path: sparky!uunet!microsoft!hexnut!joelsp
  3. From: joelsp@microsoft.com (Joel Spolsky)
  4. Subject: Re: Excel Font Question
  5. Message-ID: <1992Nov17.012142.19249@microsoft.com>
  6. Date: 17 Nov 92 01:21:42 GMT
  7. Organization: Microsoft Corporation
  8. References: <BxoC2K.8v3@da_vinci.it.uswc.uswest.com>
  9. Lines: 45
  10.  
  11. In article <BxoC2K.8v3@da_vinci.it.uswc.uswest.com> rmcinty@venezia.it.uswc.uswest.com (Robert P. McIntyre) writes:
  12. >I need some help with an Excel question.  Is it possible to interactively
  13. >test a cell or range of cells and adjust the font (e.g. bold, italic,
  14. >etc.) based on the result of the test? 
  15.  
  16. There are several approaches to accomplish what you want.
  17.  
  18. The easiest way is to change the color of the cell by using a
  19. conditional format. For example, if you set the number format of a cell
  20. to 
  21.  
  22.     [>1000] [BLUE]0; [<-1000] [RED]0; [GREEN]0
  23.  
  24. the cell will be blue if it is greater than 1000, red if it is less
  25. than -1000, and green otherwise. For more information on conditional
  26. formats, see p.224 in User's Guide 1. Unfortunately, conditional formats
  27. can only include colors, not other font attributes like bold or italic.
  28.  
  29. A more general solution would be to write a macro which scans the
  30. appropriate cells and changes their formats, based on their values. As
  31. a simple example, the following macro scans the cells from A1 to A10
  32. and makes all the negative cells bold:
  33.  
  34.     A            
  35. 1    NegBold            
  36. 2    =FOR.CELL("cel","r1c1:r10c1")
  37. 3    = SELECT(REFTEXT(cel))
  38. 4    = ACTIVE.CELL()
  39. 5    = IF(A4<0)
  40. 6    =  FORMAT.FONT(,,TRUE)
  41. 7    = END.IF()
  42. 8    = NEXT()
  43. 9    =RETURN()
  44.  
  45. You can attach this to a menu, a keyboard accelerator, or a button on
  46. the worksheet, or you can use the ON.ENTRY function to have this macro
  47. run automatically every time you change the worksheet.
  48.  
  49. --
  50. Joel Spolsky            
  51. Program Manager            
  52. Microsoft Excel            
  53. joelsp@microsoft.com        
  54.  
  55.  
  56.