You are on page 1of 69

Trn Thanh Phong

GPE - Thng 7/ 2010

Ni dung
1.

Cc vn c bn ........................................................................................................................ 5
1.1.

Gii thiu ................................................................................................................................ 5

1.2.

CF dng danh mc iu kin sn c ........................................................................................ 6

1.3.

Th t u tin ca cc CF .................................................................................................... 11

1.4.

CF s dng cc cng thc lm iu kin ............................................................................... 13

1.4.1.

a ch Tuyt i v Tng i trong cng thc ca CF................................................. 14

1.4.2.

Cng thc mng (array formula) trong CF...................................................................... 15

1.4.3.

S dng tn (Name) trong CF ....................................................................................... 15

1.4.4.

S dng Date v Time trong CF .................................................................................... 16

1.5.

2.

Thm, sao chp, thay i v xo CF..................................................................................... 17

1.5.1.

Thm CF ....................................................................................................................... 17

1.5.2.

Sao chp nh dng ca CF cho cc khc .................................................................. 17

1.5.3.

Thay i hoc xo CF.................................................................................................... 17

1.6.

Dng Go To tm kim cc c p dng CF ........................................................................... 18

1.7.

Mt s vn thng gp .................................................................................................... 19

1.7.1.

CF khng p dng ng ................................................................................................ 19

1.7.2.

Cc thit lp trong hp thoi CF bin mt ...................................................................... 19

1.7.3.

Khng th s dng mt s kiu nh dng trong CF ....................................................... 19

1.7.4.

Cc nh dng mu Font v t bng cho t ng thay i ........................................... 19

Cc v d v CF v cc k thut nng cao ................................................................................. 20


2.1.

Cc v d c bn ................................................................................................................... 20

2.1.1.

Cc vn thng gp ................................................................................................. 20

2.1.1.1.

n cc li (Hide Errors) .......................................................................................... 20

2.1.1.2.

T mu nn cc rng (ISBLANK) ........................................................................ 20

2.1.1.3.

n bt cc gi tr trng (Hide Duplicate Values) ..................................................... 21

2.1.1.4.

T mu cc gi tr trng lp trong ct (Highlight Duplicates in Column) ................... 22

2.1.1.5.

T mu cc phn t thuc danh sch (Highlight Items in a List) ............................. 22

2.1.1.6.

T mu cc con s trng vi cc con s cho trc ................................................ 23

2.1.1.7.

T mu cc ngy sp n hn (Highlight Upcoming Expiry Dates) ......................... 23

2.1.1.8.

n ni dung cc khi in (Hide Cell Contents When Printing) .................................. 24

2.1.1.9.

T mu nn cch dng (Shade Alternating Rows) .................................................. 24

2.1.1.10.

T mu nn nhm N dng cch qung (Shade Bands of Rows) ............................. 25

2.1.1.11.
T mu nn cch dng trong danh sch ang p dng Filter (Shade Alternating
Filtered Rows) ........................................................................................................................... 25
2.1.1.12.

To cc hnh nn mu (Create Coloured Shapes) .................................................. 26

2.1.1.13.

iu khin nh dng kiu Font ch ....................................................................... 27

2.1.2.

2.1.2.1.

T mu cc ngy ln hn ngy 18/09/2000 (trong B24) mt nm ........................ 27

2.1.2.2.

T mu nn cc ngy t 1/1/2001 n ngy 30/4/2001 .......................................... 28

2.1.2.3.

T mu nn cc ngy trong tun hin hnh (tun bt u l ngy ch nht)........... 28

2.1.2.4.

T mu nn cc ngy cui tun (tun bt u l ngy ch nht) ............................ 29

2.1.2.5.

T mu nn cho cc ngy l .................................................................................. 29

2.1.2.6.

T mu cc ct l ngy ch nht hng tun .......................................................... 30

2.1.2.7.

S dng hm DateDif v CF t nn cc thnh vin nh hn 18 tui .................. 31

2.1.2.8.

Kt hp TODAY v MONTH t nn nhng ngi c sinh nht trong thng ........... 31

2.1.3.

3.

Mt s v d v CF vi d liu dng Text ....................................................................... 32

2.1.3.1.

T mu nn cc cha chui cn tm.................................................................... 32

2.1.3.2.

T mu nn cc c cha chui con cn tm ........................................................ 32

2.1.3.3.

T mu nn cc cha chui c cc ch bt u ging chui cn tm .................. 33

2.1.3.4.

T mu c dng khi c mt thuc dng c cha chui cn tm ............................ 34

2.1.3.5.

T mu cc dng c lng hng tn kho ............................................................... 35

2.1.4.

2.2.

Mt s v d v CF vi d liu Date Time ................................................................... 27

Cc v d CF s dng hm thng k.............................................................................. 36

2.1.4.1.

Tm v t mu nn ca cha gi tr ln nht trong vng s liu ........................... 36

2.1.4.2.

Tm v t mu nn ca cha gi tr ln nht, nh, ba trong vng s liu............... 36

2.1.4.3.

Tm v t mu nn ca cha gi tr nh nht trong vng s liu .......................... 37

2.1.4.4.

Tm v t mu nn ca cha gi tr nh nht khc khng (0) trong vng s liu .. 37

2.1.4.5.

Tm v t mu nn ca cha gi tr nh nht, nh, ba trong vng s liu .............. 37

2.1.4.6.

Tm v t nn ca cha gi tr ln hn gi tr trung bnh cng ............................. 38

Cc v d nng cao ............................................................................................................... 38

2.2.1.

T mu cc cha cng thc ....................................................................................... 38

2.2.2.

T mu cc t ch unlock ................................................................................. 39

2.2.3.

Tm cc s c sai bit ln hn khong 5% ................................................................... 39

2.2.4.

Tm nhm 5 c gi tr cao nht/ thp nht ...................................................................... 40

2.2.5.

Tm nhm 10% c gi tr cao nht/ thp nht ................................................................. 41

2.2.6.

To s GANTT ......................................................................................................... 42

2.2.7.

CF khi c nhiu hn 3 iu kin..................................................................................... 43

nh dng theo iu kin trong Excel 2007 & 2010 ................................................................... 47


3.1.

Gii thiu .............................................................................................................................. 47

3.2.

Cc qui lut c th p dng khi s dng CF t to ................................................................ 49

3.3.

nh dng theo iu kin s dng hnh nh........................................................................... 49

3.3.1.

S dng data bars ......................................................................................................... 49

3.3.2.

S dng color scales ..................................................................................................... 52

3.3.3.

S dng Icon Sets ......................................................................................................... 54

3.3.4.

Ch cho hin th mt icon trong b Icon? ........................................................................ 57

3.4.

nh dng theo iu kin vi cng thc lm iu kin ........................................................... 59

3.4.1.

T mu cc ngy cui tun ............................................................................................ 60

3.4.2.

T mu nn cch dng .................................................................................................. 61

3.4.3.

T mu nn trng en kiu car .................................................................................... 62

3.4.4.

Hin th gi tr tng khi tt c s liu c nhp y .................................................. 63

3.5.

Mt s thao tc cn thit khi s dng nh dng theo iu kin.............................................. 64

3.5.1.

Qun l cc qui lut nh dng theo iu kin ................................................................ 64

3.5.1.1.

Thm mi qui lut nh dng .................................................................................. 65

3.5.1.2.

Hiu chnh qui lut nh dng ang c .................................................................... 65

3.5.1.3.

Sp xp th t p dng cc qui lut nh dng....................................................... 66

3.5.2.

Sao chp nh dng theo iu kin ................................................................................ 67

3.5.3.

Xa nh dng theo iu kin......................................................................................... 67

3.5.4.

Tm kim cc c p dng CF trong bng tnh .............................................................. 68

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

NH DNG THEO IU KIN TRONG EXCEL 97-2010


nh dng theo iu kin (Conditional Formatting - CF) c Microsoft b sung vo Excel k t phin
bn Microsoft Excel 97. CF trong Excel l mt cng c mnh gip chng ta nh dng cc chui vn bn
trong cc , cc gi tr v cc v mu sc, kiu mu nn, k khung
CF khi p dng vo cc (cell) n s ln cc nh dng thng thng ca v mu sc, kiu th
hin vn bn v s Tuy nhin nu chng ta xo b CF ca cc th nh dng c trc kia ca cc
ny s c phc hi.
CF trong cc phin bn Excel 2003 tr v trc c mt s gii hn v s lng iu kin (ti a l 3) v
iu ny c khc phc trong phin bn Excel 2007 vi s lng iu kin cho php l 64.
Ti liu ny s c gng trnh by v CF tht bao qut, nhm gip cc bn c th p dng c CF trong
tt c phin bn Excel hin c cng nh mt s k thut CF bng VBA. Ti liu cng cp tht chi tit
v cc im mi ca CF trong phin bn mi nht Excel 2007.
Ti liu c s dng li mt s bi vit v v d thc t v CF trn din n GPE (handung107,
levanduyet, ). Rt mong nhn c kin ng gp ca tt c cc bn, gp xin gi v
ttphong@giaiphapexcel.com

nh dng theo iu kin l cng c cho php bn p dng nh dng cho mt (cell) hay nhiu (range
of cells) trong bng tnh v s thay i nh dng ty theo gi tr ca hay gi tr ca cng thc.
V d nh bn c th to cho nh dng ca l ch in m mu xanh khi gi tr ca n ln hn 100.
Khi gi tr ca tho iu kin th cc nh dng bn to ra ng vi iu kin s c p dng cho
. Nu gi tr ca khng tho iu kin bn to ra th nh dng ca s p dng nh dng mc
nh (default formatting)

Mt c th c 3 nh dng theo iu kin. V d nh bng phn tch nhy ca Li nhun bn di


ta s dng CF cho cc C21:K31 vi 3 iu kin:
Trn Thanh Phong | Cc vn c bn

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

Nu gi tr ca ln hn 0 th n s c th hin l mu xanh (li),

Nu ga tr ca l 0 th ch s mu cam (ho vn),

V nu gi tr ca nh hn 0 th ch mu (l).

Bn ch rng CF ging nh vic thm mt hay nhiu cng thc vo mi mi khi bn s dng, v vy
p dng CF cho mt s ln cc c th gy ra vic thc hin chng trnh b chm i. Do bn hy
ch khi p dng CF cho mt s ln cc trong bng tnh.
Hai minh ho n gin trnh by ch l phn ni rt nh v kh nng ca CF, cc phn tip theo s
gip bn tng bc tip cn v lm ch CF mt tnh nng tuyt vi ca Excel.

Trong phn ny s trnh by v tu chn CF n gin nht l Cell Value is trong hp thoi CF, v kt
hp vi cc ton t trong danh sch sn c ra iu kin nh dng. Hp nh dng theo iu kin cho
Excel XP c th hin hnh di y.

Trong c cc tu chn:

Cell Value Is: cn c vo gi tr cha trong lm i s so snh v t p dng cc nh


dng nu tho mn iu kin (iu kin tr v TRUE trong kt qu so snh).

Trn Thanh Phong | Cc vn c bn

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Formula Is: cn c vo kt qu tnh ton ca cc cng thc lm i s so snh v t p


dng cc nh dng nu tho mn iu kin (kt qu so sanh l TRUE). Phn ny s trnh by
mc sau.

Gii thch cc ton t so snh:

Between: gi tr trong nm trong on t a n b (bao gm 2 cn trn v di a, b)

Not between: gi tr trong khng nm trong on [a, b]

Equal to: gi tr trong bng (=) vi gi tr so snh

Not equal to: gi tr trong khng bng () gi tr so snh

Greater than: gi tr trong ln hn (>) gi tr so snh

Less than: gi tr trong nh hn (<) gi tr so snh

Greater than or equal to: gi tr trong ln hn hoc bng () gi tr so snh

Less than or equal to: gi tr trong nh hn hoc bng () gi tr so snh

V d 2.1: Dng CF nh dng cho cc trong vng B4:E12 sao cho cc gi tr ln hn 100 s t mu
ch xanh v in m.
B1. Chn vng cn nh dng B4:E12
B2. Vo Format | chn Conditional Formatting hp thoi Conditional Formating hin ra
B3. Chn cc tu chn nh hnh sau:

Ti Condition 1, chn tu chn l Cell Value Is

Chn ton t so snh l greater than

Nhp vo gi tr 100 ti hp trng bn phi

B4. Nhn nt Format hp thoi Format Cells xut hin nh hnh sau

Chn Bold (In m) ti Font style

Chn mu xanh ti Color

Nhn OK hon tt nh dng


Trn Thanh Phong | Cc vn c bn

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

B5. Nhn OK bt u p dng CF cho cc trong vng ang chn.


V d 2.2: Dng CF nh dng cho cc trong vng H4:K12 sao cho cc gi tr t 80 n 100 s t mu
ch xanh, in m v nn mu vng; cc cn li t ch mu tm v nn mu xm.
B1. Chn vng H4:K12 cn nh dng CF
B2. Vo Format | chn Conditional Formatting hp thoi Conditional Formating hin ra
B3. Chn cc tu chn nh hnh sau:

Ti Condition 1, chn tu chn l Cell Value Is, chn ton t so snh l between v nhp vo gi
tr 80 v 100 ti 2 trng k bn. Nhn nt Format:
o

Ti ngn Font chn Bold ti Font style, chn tip mu xanh ti Color

Chuyn qua ngn Patterns v chn mu vng ti Cell shading

Nhn OK hon tt CF1.

Nhn nt Add >> thm iu kin mi

Ti Condition 2, chn tu chn l Cell Value Is, chn ton t so snh l not between v nhp vo
gi tr 80 v 100 ti 2 trng k bn. Nhn nt Format:
o

Ti ngn Font chn mu tm ti Color

Chuyn qua ngn Patterns v chn mu xm ti Cell shading

Nhn OK hon tt CF2.

Trn Thanh Phong | Cc vn c bn

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B4. Nhn OK bt u p dng CF cho cc trong vng ang chn v bn di l kt qu

V d 2.3: Dng CF nh dng cho bng kt qu phn tch nhy ca Li nhun ti vng C21:K31 vi
3 iu kin:

Nu gi tr ca ln hn 0 th n s c th hin l mu xanh (li),

Nu ga tr ca l 0 th ch s mu cam (ho vn),

V nu gi tr ca nh hn 0 th ch mu (l).

Bn hy t thc hin cc thao tc sao cho cc CF1, CF2 v CF3 nh hnh sau:

Trn Thanh Phong | Cc vn c bn

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Lu cc i s trong iu kin so snh c th dng tham chiu n a ch thay cho cc hng s.


V d 2.4. V d ta c bng d liu B36:F40 nh hnh di, hy dng CF t mu vng cho cc cha
gi tr bng vi gi tr trong F42. S dng a ch tham chiu thay cho hng s trong cc iu kin so
snh.
B1. Chn vng B36:F40
B2. Vo Format | chn Conditional Formatting hp thoi Conditional Formating hin ra
B3. Chn cc tu chn nh hnh sau:

Chn tu chn l Cell Value Is, chn ton t so snh l greater than v nhp vo tham chiu
=F42 ti trng k bn. Nhn nt Format, chn ngn Patterns v chn mu vng ti Cell
shading, nhn OK hon tt

B4. Nhn OK bt u p dng CF cho cc trong vng ang chn

Trn Thanh Phong | Cc vn c bn

10

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

Liu chng ta c th p dng nhiu hn 3 iu kin cho gi tr trong cc khi s dng cc phin bn
Excel 2003 tr v trc khng? Cu tr li cho vn ny l c th, chng ta s tip tc tho lun v
CF trong nhng bi tip theo.

Khi bn c hn mt iu kin p dng cho mt (cell) hay mt vng (range) th cc CF ny s c p


dng theo trnh t u tin ca chng, cc CF nm trn s c mc u tin cao hn cc CF nm di. i
vi Excel 2003 tr v trc th trnh t u tin l CF1 CF2 CF3, i vi Excel 2007 CF no nm
trn trong danh sch s u tin hn CF nm di. Do vy chng ta phi tht cn thn khi sp xp th t
u tin ca cc CF nhm trnh cc kt qu khng mong mun. Bng tm tt bn di m t cch thc
thi CF ca Excel trong cc phin bn trc Excel 2007.
Tr v

True

V
nu
CF2

Tr v

Th thc thi

True hoc False

V
nu
CF3

True hoc False

CF1, b qua CF2 v CF3

CF1

False

CF2

True

CF3

True hoc False

CF2, b qua CF3

CF1

False

CF2

False

CF3

True

CF3

CF1

False

CF2

False

CF3

False

Khng lm g c

Nu

Tr v

CF1

im khc bit v CF trong Excel 2007


Excel 2007 cho php p dng nhiu CF vo cng mt (cell) hay vng (range) nu cc
CF ng (True) trong khi Excel 2003 tr v trc th ch p dng duy nht mt CF ng
c th t u tin cao hn v b qua cc CF c u tin thp hn mc d n ng. Trong
Excel 2007, khi chng ta thit lp nhiu CF cho mt vng cc trong bng tnh, v khi c
nhiu CF ng (TRUE) ng thi th khi c kh nng cc CF ny c mu thun vi
nhau:

Khi cc CF khng mu thun vi nhau: V d nh CF1 s p dng nh dng


cho cc l ch in m v CF2 s p dng nh dng cho cc ch mu xanh.
Khi c CF1 v CF2 ng th khng c mu thun xy ra v cc tho iu kin s
c nh dng ch mu xanh v in m.

Trn Thanh Phong | Cc vn c bn

11

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Khi cc CF c mu thun vi nhau: V d nh CF1 s p dng nh dng cho


cc l ch mu v CF2 s p dng nh dng cho cc ch mu xanh. Khi
c CF1 v CF2 ng th c mu thun xy ra v cc tho iu kin s ch c
p dng nh dng ca CF1 l ch mu (v CF1 c mc u tin cao hn CF2).

Nhm m bo tnh tng thch ngc vi cc phin bn Excel 2003 tr v trc, khi cc
bn s dng CF trong Excel 2007 th nn s dng tu chn Stop If True trong hp thoi
Manage Rules.

Nu chn Stop If True ti CF1 th Excel ch kim tra duy nht CF1 b qua tt c
cc CFs bn di CF1.

Nu chn Stop If True ti CF2 th Excel s kim tra CF1 v CF2 b qua tt c cc
CFs bn di CF2.

Nu chn Stop If True ti CF3 th Excel s kim tra CF1, CF2 va2 CF3 b qua tt
c cc CFs bn di CF3. Nhm m bo tnh tng thch ngc vi cc phin
bn Excel c th bn nn chn Stop If True ti CF3.

Nu chn Stop If True cho tt c cc CF th nh dng tr v trong Excel 2007 s


ging nh nh dng tr v trong Excel ca cc phin bn trc...

V d 3.1: Vng a ch B3:B8 c p dng CF vi 3 iu kin sau:

Nu gi tr trong ln hn 10 th nh dng ch in m

Nu gi tr trong ln hn 20 th nh dng ch mu

Nu gi tr trong ln hn 30 th nh dng nn mu cam

Hnh trn trnh by cc qui nh ca cc CF1, CF2 v CF3 v kt qu tr v ch l ca CF1, cc CF2 v


CF3 mc d ng nhng b b qua.

Trn Thanh Phong | Cc vn c bn

12

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Hnh trn trnh by cc qui nh ca cc CF1, CF2 v CF3 v tu chn Stop If True cho CF3. Kt qu tr
v ch l p dng tt c cc nh dng ca CF1, CF2 v CF3 cho cc tho iu kin. Nu chn Stop If
True cho c 3 CF1, CF2 v CF2 th kt qu nh dng tr v s ging nh ca Excel 2003 tr v trc.

Ngoi vic s dng tu chn Cell Value Is v cc php so snh, bn c th xy dng nhng cng thc
ring ca bn xc nh khi no th CF c p dng. s dng cng thc ring trong CF, bn hy
thay i tu chn Cell Value Is sang Formula Is trong hp thoi CF, v a cng thc ca bn vo
khung trng nhp liu bn cnh. Kt qu cng thc ca bn nn tr v gi tr lun l True (1) hay False
(0). Nu cng thc bn tr v gi tr True th CF s c p dng. Nu cng thc ca bn tr v gi tr
False th CF s khng c p dng.
Cc cng thc phi bt u l du bng (=), trong cng thc khng th tham chiu trc tip n mt
hay mt vng mt worksheet hay workbook khc (Excel 2007 cho php iu ny). Chng ta c th
nh ngha tn (name) tham chiu n d liu trn cc vng ca cc sheet hay workbook khc. Bn
khng th s dng nhng hm trong module Add-in, nhng bn c th s dng cc hm t nh ngha
da trn bng VBA trong cng thc iu kin.
Ngoi ra bn cn c th nhp vo mt trn sheet hin hnh tham chiu n d liu trong mt sheet
ca workbook khc sau khi khai bo iu kin cho CF th bn ch cn tham chiu n gi a ch
ny.
V d 4.1. Bn mun tham chiu n d liu trong A5 trong Sheet1 ca workbook Baocao chng hn,
th ti Sheet ang thc hin CF bn chn mt no nhp vo a ch nh sau:
=[Baocao.xls]Sheet1!A5 v khi khai bo i s iu kin cho CF bn ch cn tham chiu n gi a
ch ny.

Trn Thanh Phong | Cc vn c bn

13

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Mt thun li ca vic s dng cng thc trong CF l cho php bn thay i nh dng ca mt da
trn gi tr ca mt khc.
V d 4.2. Hy t ch mu cho cc ti A13:A18 khi cc tng ng ct B ln hn 10
B1. Chn vng A13:A18
B2. Vo Format | chn Conditional Formatting hp thoi Conditional Formating hin ra
B3. Chn cc tu chn:

Chn Formula is v nhp

Ti trng k bn c th s dng cng thc =IF(B13>10,TRUE,FALSE), hay n gin hn


=B13>10 hay =$B13>10 hay =B13:B18>10 u c. Cch dng a ch trong cng thc ca
CF s c trnh by trong phn sau.

Nhn nt Format v chn mu trong ngn Font ca hp thoi Format Cells

Nhn OK hon tt chn mu cho ch

B4. Nhn OK hon tt CF.

Khi bn s dng cng thc trong CF, bn cn nhn thc c s khc nhau gia a ch tuyt i v
a ch tng i. Nu bn s dng nh dng theo iu kin p dng cho nhiu (range of cells), th
bn s dng a ch tng i.
V d 4.3. Gi s rng chng ta mun p dng nh dng theo iu kin cho vng A13:A18, s c t
ch mu nu gi tr trong vng B13:B18 ln hn 10. Chng ta c th dng cng thc =B13>10
lm iu ny. Tc l gi s B14 c gi tr l 11 th gi tr trong A14 s c t ch . l iu m
chng ta thng mun. Tuy nhin gi s rng chng ta mun nh dng khong A13:A18 t ch mu
nu gi tr B13 ln hn 10, tc l mi trong vng A13:A10 s lun lun c so snh vi B13.
Trong trng hp ny chng ta phi s dng cng thc =$B$13>10.
Trn Thanh Phong | Cc vn c bn

14

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Khi dng iu kin =$B$13>10 kt qu tr v False p dng CF ny cho ton vng A13:A18
khng c no c t ch mu (i chiu vi v d 4.2 thy s khc bit).

CF thc thi cc cng thc theo cch thc thc thi ca cng thc mng trong bng tnh, do vy bn c
th s dng cc cng thc mng trong CF. Tuy nhin, kt thc cng thc mng trong CF bn khng cn
nhn t hp phm Ctrl+Shift+Enter kt thc cng Excel lun x l cc cng thc trong CF theo cch
thc ca cng thc mng trong bng tnh.

Nh ni trn, cc cng thc trong CF khng th tham chiu n cc trong mt sheet khc ca
cng mt workbook. Tuy nhin bn c th khc phc iu ny bng cch s dng tn (name). nh
ngha mt tn tham chiu n mt vng ca sheet khc, v s dng tn trong cng thc ca bn (vi
ch cc a ch tuyt i v tng i nh ni phn trn).
V d 4.4. Gi s rng bn mun A22 trong sheet tn CFI.4 mu m nu gi tr bn nhp vo
trong A22 khng c trong danh sch cc gi tr trong vng A1:A10 nm trong sheet tn l Ref. Nu bn
lp cng thc nh sau th s b bo li =COUNTIF(Ref!$A$1:$A$10,A22)=0. khc phc iu ny bn
t tn Mylist tham chiu n vng =Ref!$A$1:$A$10 v s dng tn ny trong cng thc ca bn nh
sau: =COUNTIF(MyList,A22)=0

Trn Thanh Phong | Cc vn c bn

15

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

Sheet Ref

Sheet
CFI.4

Dates v times trong CF c x l di dng cc con s tun t. V d nh bn mun so snh gi tr


trong cc vi ngy 17/02/2007 th chnh l bn so snh vi con s tun t l 39130.
V d 4.5. Hy t nn mu xanh cho cc thuc vng s liu B28:B37 vi iu kin Ngy vng
A28:A37 tng ng phi ln hn ngy 20/02/2007 (c s tun t l 39133).
B1. Chn vng B28:B37 v vo hp thoi CF
B2. Chn Formula Is v nhp vo cng thc =A28>39133
B3. Nhn nt Format, vo ngn Pattern, chn mu xanh
B4. Nhn OK hai ln hon tt CF.

Trn Thanh Phong | Cc vn c bn

16

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B1. Chn cc cn b sung CF


B2. Chn tu chn l Cell Value Is hay Formula Is tu bn v nhp cc i s cn thit ca CF vo
B3. Nhn nt Format v chn nh dng ph hp vi yu cu: t mu ch, nn, mu nn, k khung,
B4. Nhn nt Add..v lp li cc bc 1, 2 v 3 thm CF mi.

B1. Chn cc c CF m ta mun sao chp


B2. Nhn nt Format Painter (
dng CF ang sao chp.

) trn thanh thc n Formatting v qut vo cc m ta mun p

Thay i nh dng ca CF: nhn vo nt Format ca CF m bn mun thay i nh dng trong


hp thoi Conditional Formatting (mi CF s c mt nt Format ring). Nhn cc nt Clear
xo b nh dng c v chn li nh dng mi (hoc chn lun nh dng mi cng c).

Xo cc CF: nhn vo nt Delete trong hp thoi Conditional Formatting v chn cc CF m bn


mun xo, sau nhn nt OK xo.
Trn Thanh Phong | Cc vn c bn

17

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Khi bn mun xo nhanh tt c cc CF v tt c cc nh dng khc trong cc ang chn th


vo thanh thc n Edit | chn Clear | chn tip Formats.

chn tt c cc ang c p dng CF bn lm cc bc sau:


B1. Chn mt bt k trn sheet (hoc chn mt ang p dng CF)
B2. Vo thanh Edit | chn Go To (Ctrl+G)
B3. Nhn vo nt Special
B4. Nhn vo tu chn Conditional formats. Khi c 2 tu chn km theo ti Data validation

Chn All: kt qu s chn tt c cc c p dng CF

Chn Same: kt qu s tr v tt c cc c p dng CF ging vi m bn chn bc 1.


Nu chn bc 1 khng c p dng CF th s c thng bo khng tm thy

Trn Thanh Phong | Cc vn c bn

18

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Khi thy kt qu nh dng tr v ca CF khng ng bn hy kim tra li:

Kim li vic p dng nhiu CF cho hay vng: Nu bn p dng nhiu CF cho mt hay
vng v nu c nhiu hn mt CF l ng (True) th Excel ch p dng CF ng u tin c th
t u tin cao.

Kim tra xem cc iu kin ca CF c giao nhau hay khng: Nu cc iu kin trong cc CF
b trng hay giao nhau mt phn th Excel cng ch p dng iu kin ng u tin. V d nh
bn xc nh iu kin t mu nn vng ti CF1 cho cc c gi tr t 100 n 200, v ti
CF2 bn li qui nh p dng t mu nn cho cc gi tr nh hn 120. Khi cc cha gi
tr t 100 n 119.999999999999 vn s p dng nh dng ca CF1.

Kim tra li cc a ch tham chiu: Nu bn dng cc cng thc trong iu kin ca cc CF


th hy a ch tham chiu ny c kh nng b sai.

Bn kim tra li xem cc m bn ang chn c th ang p dng nhiu loi CF khc nhau v
hp thoi CF ch c th hin th thng tin thit lp ca mt loi CF ti mt thi im m thi.

Bn hy chn li cc khc v vo li hp thoi CF ln na.

Chng ta khng th nh dng cao dng hoc rng ct bng CF

Khi chng ta p dng CF cho cc th Excel s p dng cc nh dng cho ph thuc vo gi tr trong
cc hay kt qu lun l tr v t cc cng thc. Do vy bn hy kim tra lai:

Nu CF dng tu chn Cell Value Is cho gi tr trong cc ang chn th Excel xem gi tr cha
trong cc l cc chui ASCII. Do vy, cc nh dng nh in m, t mu ch c th thay i
nu ni dung ca thay i.

nh dng ca cc CF (nu CF ng) s ln nh dng thng thng ca Excel (cc nh


dng dng lnh Fotmat | Cell ).

Trn Thanh Phong | Cc vn c bn

19

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

Chng ta c th dng CF kim tra cc li trong cng thc ca cc trn bn tnh v thay i nh
dng ca chng. V d sau bn s thy khi cc ct A cha s 0 th kt qu ct C s c li #DIV/0.
B1. Chn vng C2:C5
B2. Vo Format | Conditional Formatting
B3. Chn Formula Is trong Condition 1
B4. Nhp vo cng thc sau:
=ISERROR(C2) : kim tra tt c cc li
=ISNA(C2) : ch kim tra li #N/A thi
=ISERR(C2) : kim tra cc li ngoi tr li #N/A
B5. Nhn nt Format, chn mu ch trng vi mu ca ( y l mu trng)
B6. Nhn OK, v nhn tip OK

B1. Chn vng A1:C10


B2. Vo Format | Conditional Formatting
B3. Chn Formula Is trong Condition 1
B4. Nhp vo cng thc: =ISBLANK(A1)
B5. Nhn nt Format, chn mu nn xanh trong ngn Patterns
B6. Nhn OK, v nhn tip OK

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

20

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

Ghi ch nhm hm IS
Dng kim tra kiu gi tr trong hoc cc tham chiu
Hm

Tr v TRUE nu

ISBLANK

Gi tr kim tra l rng (empty cell)

ISERR

Gi tr kim tra l cc li ngoi tr li #N/A.

ISERROR

Gi tr kim tra l cc li (#N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, #NULL!).

ISLOGICAL

Gi tr kim tra l gi tr lun l

ISNA

Gi tr kim tra l li #N/A (value not available)

ISNONTEXT

Gi tr kim tra khng phi kiu TEXT (lu rng (blank cell) xem nh khng thuc
kiu TEXT)

ISNUMBER

Gi tr kim tra l cc con s

ISREF

Gi tr kim tra l cc tham chiu

ISTEXT

Gi tr kim tra l cc chui (kiu TEXT)

V d nh hnh bn di, chng ta s dng CF nh dng mu ch ca cc gi tr trng trong ct A


(Region) bng cch t mu trng n chng i cho d theo di.
B1. Chn vng A2:A5
B2. Vo Format | Conditional Formatting
B3. Chn Formula Is ti Condition 1
B4. Nhp vo cng thc =A2=A1
B5. Nhn chn Format, chn mu ch sao cho trng vi mu ca (mu trng)
B6. Nhn OK, v nhn tip OK

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

21

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B1. Chn vng A2:A11


B2. Vo Format | Conditional Formatting
B3. Chn Formula Is ti Condition 1
B4. Nhp vo cng thc: =COUNTIF($A$2:$A$11,A2)>1
B5. Nhn nt Format, chn mu ch l mu xanh v in m
B6. Nhn OK, v nhn tip OK

B1. To danh sch C2:C4 (gi s t tn l CodeList)


B2. Chn vng s liu A2:A7
B3. Vo Format | Conditional Formatting
B4. Chn Formula Is t Condition 1
B5. Nhp vo cng thc: =COUNTIF($C$2:$C$4,A2)
hoc nu dng Name cho danh sch th nhp vo: =COUNTIF(CodeList,A2)
B6. Nhn nt Format, chn mu nn l xanh nht
B7. Nhn OK, v nhn tip click OK

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

22

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

Trong v d ny chng ta dng CF t mu nn cc cc cha cc con s trong vng B2:G4 (vng


cha cc con s ca v s) nu n xut hin trong vng B6:G6 (vng kt qu x s).
B1. Chn vng B2:G4
B2. Vo Format | Conditional Formatting
B3. Chn Formula Is ti Condition 1
B4. Nhp vo cng:

=COUNTIF($B$6:$G$6,B2)

B5. Nhn nt Format , chn mu nn l xanh nht


B6. Nhn OK, v nhn tip OK

T mu cc khon phi tr sp n hn trong 30 ngy na. Trong v d ny cc ngy ht hn cha


trong vng A2:A4.
B1. Chn vng A2:A4
Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

23

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com
B2. Vo Format | Conditional Formatting
B3. Chn Formula Is ti Condition 1

B4. Nhp vo cng thc: =AND(A2-TODAY()>=0,A2-TODAY()<=30)


B5. Nhn nt Format, chn mu xanh in cho ch
B6. Nhn OK v nhn tip OK.

Bn c th dng CF n ni dung cc khi in n. Trong v d ny chng ta s t mu trng cho ch


trong cc B2:F4 khi H1 cha k t x. Mun in cc b n th xo k t x torng H1.
B1. Chn vng B2:F4
B2. Vo Format | Conditional Formatting
B3. Chn Formula Is ti Condition 1
B4. Nhp vo cng thc: =$H$1="x"
B5. Nhn nt Format , chn nh dng cc ch mu trng
B6. Nhn OK, v nhn tip OK

B1. Nhp chut vo nt Select All chn tt c bng tnh


B2. Vo Format | Conditional Formatting
B3. Chn Formula Is ti Condition 1
Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

24

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com
B4. Nhp vo cng thc: =MOD(ROW(),2)

B5. Nhn nt Format, vo ngn Patterns chn mu nn xanh nht


B6. Nhn OK, v nhn tip OK

Mun t mu nn cch N dng th dng cng thc: =MOD(ROW(),N)=0


Mun t mu nn cch N ct th dng cng thc: =MOD(COLUMN(),N)=0

Bn c th dng CF t mu nn cho mt nhm dng trn bng tnh. V d ny s minh ho cch t


mu nn cch qung 3 dng.
B1. Nhn chut ln nt Select All chn ton b sheet
B2. Vo Format | Conditional Formatting
B3. Chn Formula Is ti Condition 1
B4. Nhp vo cng:

=MOD(ROW(),6)<3

B5. Nhn nt Format, vo ngn Patterns chn mu nn l mu xm


B6. Nhn OK, v nhn tip OK

B1. Chn vng A2:B29


Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

25

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com
B2. Vo Format | Conditional Formatting
B3. Ti Condition 1 chn Formula Is
B4. Nhn vo cng thc:

=MOD(SUBTOTAL(3,$A$1:$A2),2)

B5. Nhn chut vo nt Format , vo ngn Patterns, chn mu nn xm


B6. Nhn OK, v nhn tip OK
B7. Khi p dnh Auto Filter danh sch th cc hng vn c t nn cch dng.

Mun t mu nn cch N dng th dng cng thc: =MOD(SUBTOTAL(3,$A$1:$A2),N)

Bn c th dng CF kt hp font ch to nn cc hnh nn mu trong cc . Trong v d ny chng ta


s t hnh nn mu trong vng C3:C7 tu thuc vo gi tr trong cc ct B bn cnh. Nu gi tr nh
hn 10 th bn ct C cnh bn s l hnh trn mu , nu gi tr ln hn 30 th hin hnh vung mu
xanh, cn li th hin hnh thoi mu vng.
B1.

Trong C3 nhp vo cng thc:


=IF(B3="","",IF(B3<10,"l",IF(B3>30,"n","t")))

B2.

Chp cng thc xung cho cc C4:C7

B3.

nh dng vng C3:C7 vi font ch Wingding vi mu vng

B4.

Chn vng C3:C7

B5.

Vo Format | Conditional Formatting

B6.

Ti Condition 1 chn Formula Is

B7.

Nhp vo cng thc:


=$B3<10

B8.

Nhn nt Format v chn mu font ch l mu , sau nhn nt OK.

B9.

Nhn nt Add,

B10. Ti Condition 2 chn tip Formula Is


B11. Nhp vo cng thc:
=$B3>30
Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

26

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B12. Nhn nt Format, v chn mu xanh cho font ch, sau nhn nt OK.
B13. Nhn nt OK

B1. Chn vng A1:C10


B2. Nhp ch i vo E1
B3. Vo CF, chn Formula Is v nhp vo cng thc =$E$1=i"
B4. Nhn nt Format, chn Italic ti Font Style
B5. Nhn OK v nhn tip OK ln na

B1. Chn vng A2:B21


B2. Vo CF v nhp vo cng thc: =$A2>DATE(YEAR($B$24)+1,MONTH($B$24),DAY($B$24))
B3. nh dng nn mu xanh
Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

27

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B1. Chn vng D2:E21


B2. Vo CF v nhp vo cng thc: =AND($D2>=DATE(2001,1,1),$D2<=DATE(2001,4,30))
B3. nh dng nn mu xanh

B1. Chn vng G2:H21


B2. Vo CF v nhp vo cng thc:
=AND($G2>(TODAY()-WEEKDAY(TODAY())),$G2<=(TODAY()-WEEKDAY(TODAY())+7))
Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

28

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com
Hoc dng cng thc sau:

=($G2>(TODAY()-WEEKDAY(TODAY())) * ($G2<=(TODAY()-WEEKDAY(TODAY())+7))
B3. Chn mu nn xanh

B1. Chn vng N2:O21


B2. Vo CF v nhp vo cng thc: =OR(WEEKDAY($N2)=1,WEEKDAY($N2)=7)
B3. Chn mu nn xanh

Chng ta c th t tn cho vng d liu cha cc ngy l


Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

29

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com
B1. Chn vng Q2:Q21

B2. Vo CF v nhp vo cng thc: =ISNUMBER(MATCH($Q2,$S$2:$S$4,0))


B3. Chn mu nn l mu xanh

B1. Nhp ngy u ca thng vo U3


B2. Ti V3 nhp vo =U3, ti W3 nhp vo

=V3+1

, sao chp W3 cho cc X3:AZ3

B3. nh dng vng V3:AZ3 l dd (ch hin th ngy)


B4. Chn vng V3:AZ21
B5. Vo CF chn Formula Is v nhp vo cng thc:

=WEEKDAY(V$3)=1

B6. Chn nn mu xanh

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

30

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B1. Chn vng BB2:BC12


B2. Vo CF v nhp vo cng thc:

=DATEDIF($BC2,TODAY(), Y)<=18

B3. Chn mu nn xanh

B1. Chn vng BE2:BF12


B2. Vo CF v nhp vo cng thc:

=MONTH($BF2)=MONTH(TODAY())

B3. Chn mu nn xanh

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

31

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B1. Chn vng A1:B10


B2. Vo CF chn Formula Is v nhp cng thc:

Khng phn bit ch HOA v thng th dng:


=TRIM(A1)=o

C phn bit ch HOA v thng th dng


=EXACT("o",A1)

B3. Chn nn mu xanh

B1. Chn vng D1:D10 (F1:F10)


Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

32

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com
B2. Vo CF chn Formula Is v nhp cng thc:

Khng phn bit ch HOA v thng th dng:


=SEARCH(Mai,D1)

C phn bit ch HOA v thng th dng


=FIND("Mai",F1) hoc dng
=LEN(F1)<>LEN(SUBSTITUTE(F1,Mai,))

B3. Chn nn mu xanh

B1. Chn vng H1:H10 (J1:J10)


B2. Vo CF chn Formula Is v nhp cng thc:

Khng phn bit ch HOA v thng th dng:


=COUNTIF(H1,H*)

t nn cc c k t bt u l k t H

C phn bit ch HOA v thng th dng


=FIND("H",J1)=1

t nn cc c k t bt u l k t H

B3. Chn nn mu xanh

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

33

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B1. Chn cc dng 18 n 27 (dng 35 n 44)


B2. Vo CF chn Formula Is v nhp cng thc:

cha chui n
T mu c dng khi c cha chui n

=CountIf(18:18,Mai)

cha chui con


=CountIf(35:35,*Lan*)

T mu c dng khi c cha chui con

B3. Chn nn mu xanh

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

34

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B1. Chn vng L2:O10


B2. Vo CF chn Formula Is v nhp vo cng thc
=$O2=C
B3. Chn nn mu xanh

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

35

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B1. Chn vng A1:C10


B2. Vo CF, chn Formula Is v nhp vo cng thc
=A1=MAX($A$1:$C$10)
B3. Chn Format v chn mu nn xanh trong ngn Patterns

B1. Chn vng E1:G10


B2. Vo CF, chn Formula Is v nhp vo cng thc
=E1>=LARGE($E$1:$G$10)
B3. Chn Format v chn mu nn xanh trong ngn Patterns

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

36

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B1. Chn vng I1:K10


B2. Vo CF, chn Formula Is v nhp vo cng thc
=I1>=MIN($I$1:$K$10)
B3. Chn Format v chn mu nn xanh trong ngn Patterns

B1. Chn vng M1:O10


B2. Vo CF, chn Formula Is v nhp vo cng thc
=M1=MIN(IF($M$1:$O$10<>0,$M$1:$O$10))
B3. Chn Format v chn mu nn xanh trong ngn Patterns

B1. Chn vng Q1:S10


B2. Vo CF, chn Formula Is v nhp vo cng thc
=Q1<=SMALL($Q$1:$S$10,3)
B3. Chn Format v chn mu nn xanh trong ngn Patterns

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

37

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B1. Chn vng U1:W10


B2. Vo CF, chn Formula Is v nhp vo cng thc
=U1>AVERAGE($U$1:$W$10)
B3. Chn Format v chn mu nn xanh trong ngn Patterns

B1. To name tn l CellHasFormula c Refers to l =GET.CELL(48,A1)


B2. Chn vng A1:A10 l vng c cha cc cng thc
B3. Vo CF, chn Formula Is v nhp vo cng thc =CellHasFormula
B4. Chn nt Format vo ngn Patterns chn mu nn xanh
B5. Nhn nt OK hai ln hon tt, khi cc c cha cng thc s c t mu nn xanh

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

38

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

B1. Chn vng C1:C10


B2. Vo CF, chn Formula Is v nhp vo cng thc =CELL(protect,C1)=0
B3. Chn nt Format vo ngn Patterns chn mu nn xanh
B4. Nhn nt OK hai ln hon tt, khi cc c thuc tch unlock s c t mu nn xanh

V d chng ta c kt qu kinh doanh ca 2 nm 2006 v 2007 vi doanh s cc thng nh


bng sau:

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

39

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

Hy dng CF t mu nn xanh cho cc bn ct doanh s nm 2007 c s bin ng ln hn


khong 5% so vi doanh s ca nm 2006.
B1. Chn vng G2:G13
B2. Vo CF, ti Formula Is nhp vo cng thc sau:
=OR((G2/F2)-1>5%,(G2/F2)-1<-5%)
B3. Nhn nt Format v Patterns v chn nn mu xanh.
B4. Nhn OK hai ln hon tt

B1. Chn vng J1:J20


B2. Vo CF, chn Formula Is v nhp vo cng thc sau
tm nhm 5 phn t c gi tr cao nht dng:
=LARGE(($J$1:$K$20),MIN( 5,COUNT($J$1:$K$20)))<=J1
tm nhm 5 phn t c gi tr thp nht dng;
=SMALL(($L$1:$L$20),MIN( 5,COUNT($L$1:$L$20)))>=L1
Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

40

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com
B3. Vo Format, chn Patterns v chn nn mu tm
B4. Nhn OK hai ln hon tt

Cng tng t nh cu d tuy nhin s lng phn t tnh theo dng phn trm (%).
B1. Chn vng N1:N20
B2. Vo CF, chn Formula Is v nhp vo cng thc sau
tm nhm 5 phn t c gi tr cao nht dng:
=IF(INT(COUNT($N$1:$N$20)*10%)>0,LARGE($N$1:$N$20,INT(COUNT($N$1:$N$20)*10%)),MA
X( $N$1:$N$20))<=N1
Cch khc gn hn:
=N1>=Percentile($N$1:$N$20,90%)
tm nhm 5 phn t c gi tr thp nht dng;
=IF(INT(COUNT($P$1:$P$20)*10%)>0,SMALL($P$1:$P$20,INT(COUNT($P$1:$P$20)*10%)),MIN(
$P$1:$P$20))>=P1
Cch khc gn hn:
=N1<=Percentile($N$1:$N$20,10%)
B3. Vo Format, chn Patterns v chn nn mu tm

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

41

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com
B4. Nhn OK hai ln hon tt

Vi v d ny s gip cc bn to c mt s GANTT n gin phc v cho phn bo co d n


ca mnh.
B1. To vng d liu th nh hnh minh ho R1:V13
B2. Ti V2 nhp vo cng thc =U2-T2+1 tr v s ngy
B3. Chn W1 v nhp vo =T2
B4. Ti X1 nhp vo =W1+1 v sao chp cng thc ti X1 cho vng Y1:CW1
B5. nh dng vng W1:CW1 nh sau:

Chn vng W1:CW1

Vo Format | Cell | chn Custom ti khung Category v nhp vo khung Type l dd | OK

B6. Chn vng W2:CW13


B7. Vo CF chn Formula Is v nhp vo cng thc:
=AND(W$1>=$T2,W$1<=$U2)
B8. Chn Format vo ngn Patterns chn mu nn xanh, vo ngn Border chn ng k khung trn v
di nm ngang.
B9. Nhn OK hai ln hon tt

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

42

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

Bng mu ca Excel
Excel ch nhn bit mu theo tn ca cc mu t Color 1 n 8 (Black, White, Red, Green, Blue, Yellow,
Magenta, v Cyan). Trong s 56 mu th ch lit k c 40 mu trn bng mu ca Excel (chia lm 2
nhm: nhm trn 40 mu, nhm di 16 mu thng dng). Cc cp m mu sau trn bng mu l ging
nhau: 11 & 25, 5 & 32, 14 & 31, 8 & 28, 9 & 30, 13 & 29, 18 & 54, 20 &34, 7 & 26, v 6 & 27.
interior

Font

M mu HTML Red Green Blue Tn mu

Black

[Color 1]

#000000

White

[Color 2]

Red
Green

0 [Black]

#FFFFFF

255

255

255 [White]

[Color 3]

#FF0000

255

[Color 4]

#00FF00

255

Blue

[Color 5]

#0000FF

Yellow

[Color 6]

#FFFF00

255

255

Magenta

[Color 7]

#FF00FF

255

Cyan

[Color 8]

#00FFFF

255

[Color 9]

[Color 9]

0 [Red]
0 [Green]
255 [Blue]
0 [Yellow]
255 [Magenta]
255 [Cyan]

#800000

128

[Color 10] [Color 10] #008000

128

0 [Color 10]

[Color 11] [Color 11] #000080

128 [Color 11]

[Color 12] [Color 12] #808000

128

128

0 [Color 12]

[Color 13] [Color 13] #800080

128

128 [Color 13]

[Color 14] [Color 14] #008080

128

128 [Color 14]

[Color 15] [Color 15] #C0C0C0

192

192

192 [Color 15]

[Color 16] [Color 16] #808080

128

128

128 [Color 16]

[Color 17] [Color 17] #9999FF

153

153

255 [Color 17]

[Color 18] [Color 18] #993366

153

51

102 [Color 18]

[Color 19] [Color 19] #FFFFCC

255

255

204 [Color 19]

[Color 20] [Color 20] #CCFFFF

204

255

255 [Color 20]

[Color 21] [Color 21] #660066

102

102 [Color 21]

[Color 22] [Color 22] #FF8080

255

128

128 [Color 22]

[Color 23] [Color 23] #0066CC

102

204 [Color 23]

204

204

255 [Color 24]

[Color 25] [Color 25] #000080

128 [Color 25]

[Color 26] [Color 26] #FF00FF

255

255 [Color 26]

[Color 27] [Color 27] #FFFF00

255

255

0 [Color 27]

[Color 24] [Color 24] #CCCCFF

0 [Color 9]

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

43

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

[Color 28] [Color 28] #00FFFF

255

255 [Color 28]

[Color 29] [Color 29] #800080

128

128 [Color 29]

[Color 30] [Color 30] #800000

128

0 [Color 30]

[Color 31] [Color 31] #008080

128

128 [Color 31]

[Color 32] [Color 32] #0000FF

255 [Color 32]

[Color 33] [Color 33] #00CCFF

204

255 [Color 33]

[Color 34] [Color 34] #CCFFFF

204

255

255 [Color 34]

[Color 35] [Color 35] #CCFFCC

204

255

204 [Color 35]

[Color 36] [Color 36] #FFFF99

255

255

153 [Color 36]

[Color 37] [Color 37] #99CCFF

153

204

255 [Color 37]

[Color 38] [Color 38] #FF99CC

255

153

204 [Color 38]

[Color 39] [Color 39] #CC99FF

204

153

255 [Color 39]

[Color 40] [Color 40] #FFCC99

255

204

153 [Color 40]

[Color 41] [Color 41] #3366FF

51

102

255 [Color 41]

[Color 42] [Color 42] #33CCCC

51

204

204 [Color 42]

[Color 43] [Color 43] #99CC00

153

204

0 [Color 43]

[Color 44] [Color 44] #FFCC00

255

204

0 [Color 44]

[Color 45] [Color 45] #FF9900

255

153

0 [Color 45]

[Color 46] [Color 46] #FF6600

255

102

0 [Color 46]

[Color 47] [Color 47] #666699

102

102

153 [Color 47]

[Color 48] [Color 48] #969696

150

150

150 [Color 48]

[Color 49] [Color 49] #003366

51

102 [Color 49]

[Color 50] [Color 50] #339966

51

153

102 [Color 50]

[Color 51] [Color 51] #003300

51

0 [Color 51]

[Color 52] [Color 52] #333300

51

51

0 [Color 52]

[Color 53] [Color 53] #993300

153

51

0 [Color 53]

[Color 54] [Color 54] #993366

153

51

102 [Color 54]

[Color 55] [Color 55] #333399

51

51

153 [Color 55]

[Color 56] [Color 56] #333333

51

51

51 [Color 56]

Di y l bng quy nh m cho nh dng ty bin:


NH DNG KIU CHO GI TR L S

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

44

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com
M nh dng

Gii thch

General

Hin th s theo nh dng tng qut

Biu th cho 1 con s. Ch hin th s c ngha trong (khng hin th s 0

0 (s khng)

Biu th cho 1 con s. Hin th s k c 0 (s khng) v nu gi tr trong l s


thp phn th ch hin th l s khng c phn thp phn. VD: 12.4 th hin th l
12, cn nu 12.5 th hin th l 13

Biu th cho 1 con s. Thm khong trng pha trc hoc pha sau ca con s.
Dng canh thng theo n v, chc, trm cho cc lin k trn v di.

. (du chm)

Du chm phn cch thp phn. VD: Nu nhp 12.4 vo mt c m nh dng


l #.00 th s hin th l 12.40

Dp phn trm. VD: 12.4%

, (du phy)

Du phn cch hng ngn. VD: 124,000


Nu t pha sau ca m nh dng l s th n s hin th theo n v l ngn
(ch : gi tr ca khng thay i, n ch thay i hin th) VD: Nu nhp
15000000 vo mt c m nh dng l #,, th s hin th l 15. Nh vy,
nu mun nh dng theo n v l t th s nh dng l #,,,

E- E+ e- e+

Dng s khoa hc. VD: 1E+01 (10 m +1 hay bng 10), 3E-02 (3 nhn vi 10 m
-2 hay bng 0.03)

$ - + / ( ) :
khong trng

Tt c cc k t ny s hin th trong niu nh n xut hin trong m nh dng.


VD: Nu nhp 12.4 vo mt c kiu nh dng l #.0$ th s c hin th
l 12.4$

Hin th k t tip theo trong nh dng. VD: Nu nhp 12.4 vo mt c kiu


nh dng l #.0\ th s c hin th l 12.4

Hin th lp i lp li k t k tip cho n khi ni dng ca trn y chiu rng


ca . VD: Nu nhp 12.4 vo mt c nh dng l #.0* th s hin th
12.4```````

_ (du gch di)

Cho mt khong trng c chiu rng bng vi chiu rng ca k t k tip. VD:
Nu nhp 12.4 vo mt c kiu nh dng l (__#.0) th s hin th l (
12.4)

vn bn

Hin th vn bn bn trong du ngoc kp.


VD: Nu nhp 12.4 vo mt c kiu nh dng l #.0 ng th s hin th
l 12.4 ng

Biu th cho dng vn bn. VD: Nu nhp vo ch USD vo mt c kiu nh


dng l @* th s hin th l USD

[mu]

S liu trong s c hin th mu theo nh m nh dng. Cc m mu c th


dng l: Black, Blue. Cyan, Green, Magenta, Red, White, Yellow. VD: Nu nhp
12.4 vo mt c kiu nh dng l [Red] th s hin th l 12.4 c mu

[mu th n]

Hin th mu c s tng ng trn tm dy mu pallet. S n c gi tr t 0 n 56

[iu kin gi tr]

Cho php nh dng theo tiu chun tha mn gi tr no . C th p dng cho


3 phn u trong 4 phn ca cu trc ca m nh dng. VD: Nu nhp 12.4 vo
mt c m nh dng l [<11]"Low"* 0;[>20]"High"* 0;"Average"* 0;@*' th
s hin th l |Average 12| (ch l do nh dng khng c thp phn nn khi
nhp vo 12.4 th ch hin th l 12). Nu nhp vo 25 th hin th l |High 25|.
Nu nhp vo 0 th hin th l |Low 0|. Cn nu nhp vo l FETP th hin th l
|FETP|
Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

45

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

V d: Thay i mu ca gi tr trong da vo 6 iu kin nh sau:


Nu gi tr nh hn hay bng 0, font s l mu (Red Color 3)
Nu ga tr ln hn 0 nhng nh hn hay bng 20, font s l mu xanh l cy (Green Color
4)
Nu gi tr ln hn 20 nhng nh hn 31, font s l mu xanh (Blue Color 5)
Nu gi tr gia 31 v 40 th font mu nu vng (Yellow Color 6)
Nu gi tr gia 41 v 50 th font mu hng (Pink Color 7).
Nu gi tr ln hn hay bng 51 th font mu tm (Violet Color 13).

B1. thc hin c iu ny bn chn vng A30:C39, sau vo Format | Cells | chn ngn
Number | chn Custom v nhp vo hp Type nh sau:
[Red][<=0]0;[Green][<=20]0;[Blue]0
B2. Sau khi nhn OK chp nhn nh dng tu bin th vo Format | chn Conditional Formatting..

Chn Cell Value Is ti Condition 1 chn iu kin l between v nhp vo hai gi tr 31


v 40 vo hai trng k bn. Nhn nt Format | chn ngn Font | v chn mu vng ti
Color. Nhn OK hon tt CF1.

Nhn nt Add >> thm CF2. Chn Cell Value Is ti Condition 2 chn iu kin l
between v nhp vo hai gi tr 41 v 50 vo hai trng k bn. Nhn nt Format | chn
ngn Font | v chn mu hng ti Color. Nhn OK hon tt CF2.

Nhn nt Add >> thm CF3. Chn Cell Value Is ti Condition 3 chn iu kin l
greater than or equal to v nhp vo gi tr 51 vo trng k bn. Nhn nt Format | chn
ngn Font | v chn mu tm ti Color. Nhn OK hon tt CF3.

B3. Nhn OK hon tt

Trn Thanh Phong | Cc v d v CF v cc k thut nng cao

46

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Phn ny trnh by cch nh dng theo iu kin trong Excel 2007 & 2010. nh dng theo iu kin
c ci tin rt nhiu trong cc phin bn ny v cng c ny tr nn rt hu ch trong vic m hnh
ho d liu s. Trong mt s trng hp bn c th dng CF thay cho th.
Danh mc nh dng theo iu kin thit lp sn:

Cc loi nh dng theo iu kin

Vic nh dng theo iu kin c th c thc hin nhanh chng thng qua cc tp nh dng thng
dng c thit lp trc hoc ngi dng c th to qui lut nh dng mi ti New rules v qun l
cc qui lut nh dng bng cng c Manage Rules

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

47

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Hp thoi New Formatting Rule

Hp thoi Conditional Formatting Rules Manager

p dng mt qui lut CF cho cell () hoc range (vng), trc tin hy chn cc sau vo Home |
Styles | Conditional Formatting | chn lnh CF. C mt s la chn nh:

Highlight Cell Rules: Cha cc qui lut nh dng lm ni cc cha gi tr ln hn mt gi tr


xc nh, nm gia hai gi tr, cha mt chui xc nh hoc cc gi tr trng nhau,

Top Bottom Rules: Cha cc qui lut nh dng lm ni cc cha nhm gi tr ln nht, nhm
10% cc gi tr ln nht v nhm cc gi tr trn trung bnh ca tp s liu,

Data Bars: p dng cc th hnh thanh trc tip trong cc tng ng vi gi tr ang cha
trong .

Color Scales: p dng mu nu tng ng vi gi tr cha trong

Icon Sets: Hin th cc icon trc tip trong cc . Cc icon hin th ph thuc vo gi tr cha
trong .
Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

48

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

New Rule: Cho php bn chn la cc qui lut CF khc, bao gm c qui lut CF da vo kt
qu lun l ca cng thc.

Clear Rules: Xo tt c cc CF ang p dng cho cc c chn

Manage Rules: Hin th hp thoi Conditional Formatting Rules Manager, ti bn c th to


mi, chnh sa hoc xo cc qui lut CF.

Format all cells based on their values: nh dng theo iu kin cn c vo gi tr dng s
cha trong cc bng tnh. Hin th cc kiu nh dng nh l data bars, color scales, hoc icon
sets.

Format only cells that contain: nh dng theo iu kin cn c vo ni dung cha trong cc
. Chng ta c th p dng cc php so snh (ln hn, nh hn, ln hn hoc bng, nh hn
hoc bng, bng, khng bng, khong, ngoi khang). Cc qui lut c th p dng cho kiu d
liu chui, ngy thng, trng, khng trng v cc li trong . Qui lut ny ging vi nh dng
theo iu kin cn c vo ni dung trong ca cc phin bn Excel trc kia.

Format only top or bottom ranked values: Qui lut ny ch p dng nh dng nhm cc
cha gi tr s ln nht v nh nht (tnh theo phn trm).

Format only values that are above or below average: Qui lut ny p dng cho cc cha
gi tr s so snh vi gi tr trung bnh, lch chun ca tp gi tr ang p dng nh dng.

Format only unique or duplicate values: Qui lut ny p dng cho cc cha gi tr s l duy
nht hoc trng lp.

Use a formula to determine which cells to format: Qui lut ny p dng nh dng da trn
kt qu lun l ca cc cng thc.

Phn ny trnh by mt s kiu nh dng theo iu kin vi cc nh dng bng hnh nh trc quan v
sinh ng nh data bars, color scales, v icons sets.

nh dng theo iu kin ny hin th th hnh thanh trc tip trong bng tnh. Chiu di ca thanh
th da trn gi tr s ang cha trong vi s so snh tng i vi cc gi tr khc trong vng nh
dng.
V d: S dng Data Bars v th hnh thanh trc tip trong cc so snh GPD d tnh ca cc
nc Chu nm 2009.
Cch lm:
1. Chn vng B5:B59
2. Vo Home | Styles | Conditional Formatting | Data Bars | chn Orange Data Bars

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

49

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

nh dng theo iu kin s dng Data Bars


Data Bars ch cung cp 6 mu c bn, c nhiu la chn hn ta nhn vo More Rules Hp thoi
New Formatting Rule cung cp cho bn thm mt s ty chn nh:

Show bar only: n cc gi tr trong

S dng cc hp Type v Value iu chnh cch hin th ca cc thanh th theo gi tr


trong cc .

Bar Color: Danh mc cc mu cho thanh th

Cc ty chn b sung cho Data Bars


Lu : Excel lun lun hin th Data Bar cho tt c cc trong vng nh dng, k c cc cha gi tr 0
(zero). cha gi tr nh nht trong vng nh dng lun lun c chiu di thanh th bng 10% chiu
rng ca . Excel khng cung cp bt k giao din ngi dng no cho php hiu chnh gi tr ny, do
vy chng ta phi hiu chnh n bng VBA cho cc thanh th th hin c chnh xc hn. Nhp
phi chut ln tn sheet ang p dng nh dng Data Bars ri chn View Code v nhp on m sau
Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

50

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

vo ca s Code ca Sheet:

iu chnh chiu di cc thanh th


Public Sub AdjustDataBars()
Range("B5:B59").FormatConditions(1).PercentMin = 0
Range("B5:B59").FormatConditions(1).PercentMax = 100
End Sub
Sau khi on m trn c thc thi, cc thanh th s th hin gi tr chnh xc hn. Data Bars trong
phin bn Excel 2010 sp xut bn c rt nhiu ci tin v cung cp nhiu ty chn hn so vi Data
Bars trong phin bn Excel 2007. Phin bn mi cho php chng ta k khung cho cc thanh th, th
hin cc thanh th gi tr m v cho php chng ta iu chnh chiu di thanh th bng giao din
ngi dng rt d dng:

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

51

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Data Bars trong Excel 2010

p dng color scale trong nh dng theo iu kin t mu nn cc da trn gi tr cha trong c
s tng quan vi cc khc trong vng nh dng.
V d:
Chng ta s dng cc mu t nn mt bng s liu v th phn trnh duyt web nm 2009 thng k
qua cc thng. Mu cng xanh l th phn cng nhiu v mu cng th th phn cng t.

Bng s liu thng k


minh ho cc s liu thng k c trc quan hn th chng ta c th v th hoc dng CF ca
Excel 2007. V d nh chng ta s dng CF bng Color Scales. Cc bc thc hin:
1. Chn vng B4:L10
2. Vo Home | Styles | Conditional Formatting | Color Scales | chn Green Yellow Red
Color Scale.

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

52

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Thng s mc nh cho kiu CF va chn


3. Chng ta c th ty chnh thm cho CF trn bng cch vo Home | Styles | Conditional
Formatting | Manage Rules ...

Hp thoi CF Rules Managers


4. Chn Rule cn hiu chnh v nhn nt Edit Rule.... V d chng ta iu chnh li nh sau:
-

Format Style: chn kiu 3 mu l 3-Color Scale


Minimun: Lowest Value gi tr thp nht trong vng s liu ang chn
Maximun: Highest Value gi tr cao nht trong vng s liu ang chn
Midpoint: chn Percent l 5%.
Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

53

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Hp thoi Edit Formatting Rule & kt qu sau khi hiu chnh


Cu hi: Ti sao c nhng gi tr di 5% m vn t nn mu vng ng sang xanh ch khng phi l
mu vng ng sang mu ?

Mt kiu nh dng theo iu kin khc l dng cc b icon minh ha cho cc gi tr ang cha
trong . Excel 2007 dng sn 17 b icon vi s lng icon trong mi b l t 3 n 5.
Xt bng s liu v gi c phiu REE trong mt thng qua nh bng sau. Chng ta s s dng Icon
Set nh dng s thay i ca gi ti ct E.

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

54

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Bng gi c phiu REE


Chng ta s nh dng sao cho khi % thay i tng th thm vo pha trc ca hnh mi tn hng
ln mu xanh. Khi % thay i khng i (0) th thm vo pha trc ca hnh mi tn nm ngang mu
vng v nu thay i gim th thm vo hnh mi tn hng xung mu . Cc bc thc hin:
B1. Chn vng a ch E3:E22
B2. Vo Home | nhm Styles | chn Conditional Formatting | chn Icon Sets | chn kiu 3 Arrows
(Colored).

Chn kiu 3 Arrows (Colored)


B3. Vo Home | nhm Styles | chn Conditional Formatting | chn Manage Rules m hp thoi
Conditional Formatting Rules Manager | chn Rule Icon Set v nhn nt Edit Rule tin hnh
hiu chnh.

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

55

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Danh sch cc Rule


B4. Hiu chnh li cc thng s nh hnh sau. Nhn nt OK ng hp thoi Edit Formatting sau khi
hiu chnh xong.

Hiu chnh cc gi tr iu kin nh dng


B5. Nhn OK hon tt

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

56

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Kt qu nh dng s dng Icon Set

Icon Set mi trong Excel 2010

Trong mt s trng hp, chng ta ch mun s dng mt icon trong b icon. Excel khng trc tip cung
cp ty chn ny, tuy nhin chng ta c th lm c iu ny bng cch s dung 2 php nh dng
chng ln nhau.
V d nh, chng ta s nh dng cho ct H trong bng s liu trn bng cch thm vo hnh l c vi
iu kin Khi lng ln hn hoc bng mt triu n v. Cc bc thc hin nh sau:
B1. Chn vng s liu H3:H22 ca ct Khi lng
B2. Vo Home | nhm Styles | chn Conditional Formatting | chn Icon Sets | chn kiu 3 Flags.
B3. Vo Home | nhm Styles | chn Conditional Formatting | chn Manage Rules m hp thoi
Conditional Formatting Rules Manager | chn Rule Icon Set v nhn nt Edit Rule tin hnh
hiu chnh. Ti hp Value ca dng c icon l c mu xanh, bn chn >= 1000000 v chn Type li l
Number. Cc dng khc khng cn iu chnh. Nhn nt OK ng hp thoi Edit Formatting sau khi
hiu chnh xong.
Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

57

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Hiu chnh gi tr iu kin cho icon l c mu xanh


B4. T hp thoi Conditional Formatting Rules Manager, bn chn New Rule | chn kiu Rule l
Format only cells that contain. Bn chn iu kin so snh l less than v nhp vo gi tr 1000000
hp bn cnh. Nhn nt OK hon tt m khng cn thit lp cc nh dng.

Khai bo iu kin p dng nh dng


B5. Ti hp Conditional Formatting Rules Manager, bn chn Stop If True ti Rule Cell Value sau
nhn nt OK.

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

58

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Thit lp dng p dng cc qui tc nh dng c u tin thp hn


B6. Kt qu sau khi nh dng

Ch hin th mt icon trong b icon set

Ngoi vic s dng cc nh dng theo iu kin dng sn ca Excel, chng ta c th s dng linh hot
cc kt qu ca cc cng thc v hm lm iu kin nh dng.
Tng t nh vic s dng cc cng thc hay hm lm iu kin trong cc phin bn Excel 2003 tr v
trc, cc cng thc lm iu kin trong phin bn Excel 2007 & 2010 cng phi tr v cc kt qu lun
l True hoc False. Nu cng thc tr v True c ngha l iu kin c tha mn v nh dng theo
iu kin c p dng. Nu cng thc tr v False th nh dng theo iu kin khng p dng.
Bn c th truy cp vo hp nhp cng thc iu kin nh sau:
1. Vo Home | Styles | Conditional Formatting | New Rule
Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

59

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

2. Trong hp thoi New Formatting Rule | chn Use A Formula To Determine Which Cells To
Format
3. Nhp cng thc cn lm iu kin vo hp Format values where this formula is true

Hp thoi nhp cng thc lm iu kin nh dng

C vng d liu ngy thng A1:A20 nh hnh bn di, chng ta s nh dng t nn mu cho cc
ngy cui tun.

Cc bc thc hin:
B1. Chn vng A1:A20, vi A1 l hin hnh
B2. Vo Home | Styles | Conditional Formatting | New Rule
B3. Trong hp thoi New Formatting Rule | chn Use A Formula To Determine Which Cells To
Format
B4. Nhp cng thc vo hp Format values where this formula is true nh sau:
=OR(WEEKDAY(A1)=7,WEEKDAY(A1)=1)
Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

60

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

B5. Nhn nt Format | chn ngn Fill v chn mu trong hp Format Cells
B6. Nhn OK hai ln p dng nh dng.
Do hm Weekday lun tr v gi tr True cho trng, nn chng ta c th thm vo hm Isblank loi
b cc trng.
=IF(ISBLANK(A1),FALSE,OR(WEEKDAY(A1)=7,WEEKDAY(A1)=1))

Xt v d t mu cch dng cho cc trong vng A1:D18. Cc bc thc hin:


B1. Chn vng A1:D18
B2. Vo Home | Styles | Conditional Formatting | New Rule
B3. Trong hp thoi New Formatting Rule | chn Use A Formula To Determine Which Cells To
Format
Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

61

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

B4. Nhp cng thc vo hp Format values where this formula is true nh sau:
=MOD(ROW(),2)=0

B5. Nhn nt Format | chn ngn Fill v chn mu xanh nht trong hp Format Cells
B6. Nhn OK hai ln p dng nh dng.

Xt v d t mu nn trng en kiu car cho cc trong vng A1:H8. Cc bc thc hin:


B1. Chn vng A1:H8
B2. Vo Home | Styles | Conditional Formatting | New Rule
B3. Trong hp thoi New Formatting Rule | chn Use A Formula To Determine Which Cells To
Format
B4. Nhp cng thc vo hp Format values where this formula is true nh sau:
=MOD(ROW(),2)=MOD(COLUMN(),2)

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

62

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

B5. Nhn nt Format | chn ngn Fill v chn mu en trong hp Format Cells
B6. Nhn OK hai ln p dng nh dng.

Xt v d dng nh dng theo iu kin cho hin th dng tng cng trong bng s liu B2:C6, khi s
liu cc qu cha nhp vo y th s n cc gi tr trong B6:C6. Cc bc thc hin:
B1. Chn vng B6:C6
B2. Vo Home | Styles | Conditional Formatting | New Rule
B3. Trong hp thoi New Formatting Rule | chn Use A Formula To Determine Which Cells To
Format
B4. Nhp cng thc vo hp Format values where this formula is true nh sau:
=COUNT($C$2:$C$5)=4

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

63

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

B5. Nhn nt Format | chn ngn Fill v chn mu xanh trong hp Format Cells
B6. Nhn OK hai ln p dng nh dng.

Hp thoi qun l cc qui lut nh theo iu kin rt tin li cho vic kim tra, hiu chnh, xa b v
thm cc qui lut nh dng theo iu kin. Truy cp hp thoi ny theo cc bc sau: chn Home |
Styles | Conditional Formatting | Manage Rules | hp thoi Conditional Formatting Rules Manager
xut hin:

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

64

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Trong hp thoi Conditional Formatting Rules Manager:


B1. Nhn nt New Rule hp thoi New Formatting Rule xut hin

B2. Chn loi qui lut t danh sch Select a Rule Type
B3. Tu theo tu chn bc 2 th phn Edit the Rule Description tng ng s xut hin
B4. Khai bo cc thng s lm iu kin nh dng
B5. Nhn nt Format (nu c) nh dng.

B6. Nhn OK hon tt.

Trong hp thoi Conditional Formatting Rules Manager:


B1. Nhn nt Edit Rule hp thoi Edit Formatting Rule xut hin

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

65

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

B2. Thc hin cc thay i iu kin nh dng trong Edit the Rule Description

B3. Nhn nt Format (nu c) thay i nh dng.


B4. Nhn OK hon tt.

Khi c nhiu qui tc nh dng trong hp thoi Conditional Formatting Rules Manager th nhng qui
tc c xp bn trn s c u tin cao hn nhng qui tc xp bn di.

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

66

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Chn qui tc nh dng cn sp xp u tin v nhn vo nt Move Up tng mc u tin hoc


Move Down gim mc u tin.

Cc thit lp nh dng theo iu kin c lu trong (cell) ging nh cc thit lp nh dng thng
thng ca cc . Do vy, khi bn sao chp mt ang c p dng nh dng theo iu kin th bn
ng thi cng sao chp cc thit lp nh dng theo iu ca . Cc bc thc hin:
B1. Chn cha nh dng theo iu kin cn sao chp
B2. Vo Home | nhm Clipboard | chn Copy
B3. Chn cc cn p dng nh dng theo iu kin
B4. Vo Home | nhm Clipboard | nhm Paste | chn Paste Special | chn kiu Formats

B5. Nhp nt OK hon tt


Nu bn chn thm cc dng hoc ct trong vng (range) ang c nh dng theo iu kin th cc
mi chn vo trong vng ny s c p dng cng loi nh dng theo iu kin .

Khi bn xo ni dung/ gi tr ang cha trong cc ca bng tnh th cc nh dng theo iu iu ca


cc ny khng c xo i. Bn mun xo lun cc nh dng theo iu kin ca cc ny th lm
nh sau:
Cch 1:
B1. Chn vng ang cha nh dng theo iu kin
B2. Vo Home | Styles | Conditional Formatting | Manage Rules
B3. Trong hp thoi Conditional Formatting Rules Manager, chn qui lut nh dng theo iu kin
mun xo
B4. Nhn nt Delete Rule
B5. Nhn OK ng hp thoi

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

67

www.giaiphapexcel.com

nh dng theo iu kin trong Excel 97-2010

Cch 2:
B1. Chn vng ang cha nh dng theo iu kin
B2. Vo Home | Editing | Clear | Clear Formats

Hp thoi tm kim v thay th trong Excel c bao gm tnh nng tm kim cc ang p dng nh dng
theo iu kin. Cc bc thc hin:
Cch 1:
B1. M bng tnh cn tm cc ang cha nh dng theo iu kin
B2. Vo Home | nhm Editing | chn Find and Select

Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

68

nh dng theo iu kin trong Excel 97-2010

www.giaiphapexcel.com

B3. Chn Conditional Formatting


Cch 2:
B1. M bng tnh cn tm cc ang cha nh dng theo iu kin
B2. Vo Home | nhm Editing | chn Find and Select
B3. Chn Go To Special

B4. Chn Conditional formats


B5. Chn OK

~~~~~~~~~~~~~~~
Trn Thanh Phong | nh dng theo iu kin trong Excel 2007 & 2010

69

You might also like