Page 1

M ic r o s o f t E x c e l M a c r o  (



)




          

















1


  :  (Function Procedure): Function   ( ) ………………….. …………………..  ………………….. End Function 













  Function Sum(A,B) Sum = A + B End Function

 

(Sub Procedure):

Sub   () ………………….. ………………….. ………………….. End Sub

, $ % &'  - . / 0 1  !

"

#

"

(#

)

*

+

,

&



  Sub Sum() C=A+B End Sub

2


2





4 5 6 7 :  8 9 (: /2 3 /2 3 ;   8 9 (: /2 3 /<= > ? 2 3   8 9 Visual Basic (: @ 2 3 A 3

8 9 8

9

/2

(:

/2 3

3

;



BCD E ) * (: /2 3 /2  I J 1-1 2 3 ; K L MN O :

J 1-1 2   :P ' $ Q R :S R # Y

Z 3

[ K

L

\

]

^

3

;

 9 TU

K 

b

MN

2

3

V

W

X



A, ad

J 1-2 b c

2

3

e

K

2

L

3

(#

I

J 1-2 b

q

5 : ` b

c

2

3

c

2



M

  < A1 f g h W i j Microsoft k l m  n 2 3 o  p q 1 : r B A1 f g h p q 2 : BCD E ) * (: /2 3 /2 3 ; FG p q 3 : m   $  Example1 p q 4 : i j Microsoft, <`<Enter>s p

, H

FG

O

`A, aH c

;



_`

M, `

L

3



A 3


6 : B Module1 (# ) t u : p

q

8 9 v

2  }

~ o p

q p

q p

q

(:

/2

3

u

t  *  Â&#x20AC; 

w

x

3

/<= >

?

2

3



Module (# y W z = { | ? 

, Â ~ < B1 f g h W i j Excel k l m  n 2 3

1 : r B B1 f g h  2 : BCD E ) * (: /2 3 /<= > ? 2 3  FG  3 : i j Excel, <`<Enter>s

4: ` b c 2 3 A p q 5 : B Module1 (# )  t u : p

q

4


8 9

Visual Basic (:

BCD E ) K L M

*

‚

N

@

2

(:

@

3

A

, H I J 1-3 (: @

FG

J 1-3 (: @ K L M B Visual Basic Bƒ_`Y „`A…H I K

L ad

M…` 2 3 e 2 3 (# 

`A…†

^

J 1-4 Visual Basic K

J 1-4 Visual Basic

_`

L

b

c

2

3

A,

M

5


!

4 5 6 P ‡ ˆ <(# ) * !  ‰ 9 Visual Basic (: @

<(# ) * !



!





q

1 : BC(: D E FG …H I J 1-5 K L M

p

J 1-5 K

M

q

2 : <  Š ‹ 4 Œ  …BCŽ  ! A

p

L

Visual Basic (: @ 9

!

!

…`



q p

q p

q p

q

1ˆBCD E ) ‚ N (: @ FG  2ˆ<(: @ Š ‹  BVisual Basicƒ…a I Visual Basic(: @ 

p

3ˆ` Visual Basic (: @  ! A…a I K L M 4ˆ<  Š ‹ 4 Œ  …BCŽ ! …`  ! A

6


 m



m

‘   

P

™ p

q p

q



’ ! 4 ” <(# ) * ” <(# ) * ” <J— *

m m m

” ˜



š

›

<(# <(#

) )

*





|



“ˆ `A ! • – (:



A









!

!

`A *





! `A…_m

F„<`A*



1ˆBCD E ) * ‚ N (: @ FG  2ˆ<(: @ K L M BC Jƒž …Ÿ`Y „A… H I J 1-6  JK L M

J 1-6 

JK

L

M

q

3ˆ< JK L M B   ¡ `A…Ÿ<(# y * 9 ¢ £ ¤œ  ¥ ¦ U § 4 Œ …TH I J 1-7 F„K L M

p

p

q p

q

J 1-7 F„K L M 4ˆ<F„K L M Bœ     5ˆ9 ¢ £ r œ `AaH ! v 2 3  7


m

”

<(#

)

*

–

(:

A

!

q p

q

1ˆ ! ‚ N /(: @ FG …H I (: @ K L M 2ˆ<(: @ K L M `¨ © (: @ A…H I J 1-8 ¨ © (: @ K L M

p

J 1-8 ¨ ©

(:

@

K

L

M

p

q

3ˆª « ¤œ  `A¬ ¨ © (: @ K L MP ­ ® 4 …Ÿ B„œ    …ad e J

p

q

4ˆr œ `A…T

m

”

<(# p

q

p

q p

q p

q

)

<J—

*

!

F„

!

* …¯j&° * œ  J— …9 o !  1ˆ<J± ² ³ ´ µ § ¶ · m J— ² ¸ T° * Paste 4 5 …m J— » x (# ) * j/J— FG  2ˆ_J— * …`œ ¼ s… I  ½ ¾ D 3ˆBC½ ¾ D E ) * F„FG ^ K L 4 Œ …<K L M BCœ  ^ 4ˆm z = » x J— * …% ¿ 0 À …`œ „”



*

”F„”

d ¹ ‰ 9 º 3 Copy & ! D E ) * ¯ E )  … I F„ …`Y „A …a ! Á ”F

8




    

 

 



  



 

 





  



!

"

#

$



%





'

$



%

&









%

&

&

9


Ă&#x201A;

$





P    

Ă&#x192; Ă&#x201E; k Ă&#x201E; k f g f g











 - . Â&#x2C6; k Âľ (Ă&#x2026; Âľ Ă&#x2020;Ă&#x2021; Âľ Ă&#x2020;Ă&#x2C6; Ă&#x160; Ă&#x2039; h ­ Ă&#x152; h Â&#x201C;TĂ&#x160; Ă&#x2039; h Ă? Ă&#x2C6; h Â&#x201C;TĂ&#x160; Ă&#x2039;

 Ă&#x2030;

! Ă&#x2020;U

" §

#

$

Ă&#x2020;k



%

&

) 0



 p q 1Â&#x2C6;Â&#x2DC; Â&#x2122; `2 3  p q 2Â&#x2C6;_m A1 f g h W Â&#x2122; i j Microsoft k l  p q 3Â&#x2C6;$ % k 0 U § Ă&#x2020;k 0 Ă&#x2026; Âľ Ă&#x2020;k 0 Ă&#x2021; Âľ Ă&#x2020;k 0 Ă&#x17D;* Ă&#x2C6; Ă&#x2030; K Ă? 4 Â&#x201C; p q 4Â&#x2C6;f g h Ă&#x160; Ă&#x2039;Ă&#x2020;f g h ­ Ă&#x152; Ă&#x2020;f g h Ă? Ă&#x2C6; Ă&#x160; Ă&#x2039;Th Â&#x201C; p q 5Â&#x2C6;`b c 2 3 A t u  Sub ChangeCell() ActiveCell.FormulaR1C1 = "Microsoft"

With Selection.Font .Name = "; Ă? Ă&#x2018; Âľ " .Size = 14 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlNone .ColorIndex = 3 End With Selection.Font.Bold = True Selection.Font.Italic = True Selection.Font.Underline = xlSingle With Selection .HorizontalAlignment = xlLeft .VerticalAlignment = xlBottom .WrapText = False

k

k

k

Âľ

Âľ

Ă&#x160;

0 U



Ă&#x2020;Ă&#x201E;

k



§

Ă&#x2039;

Ă&#x2026; Ă&#x2021;

Âľ Âľ

K

Ă&#x2C6;

Ă?

4

Ă&#x2030;

h

Â&#x201C;

Â&#x201C;Ă&#x2019;Ă&#x201C;

Ă&#x201D;

Ă&#x2022;

Ă?

Ă&#x2013;

10


.Orientation = xlHorizontal .AddIndent = False End With With Selection.Borders(xlLeft ) .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlRight) .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlTop ) .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlBottom ) .Weight = xlThin .ColorIndex = xlAutomatic End With

f

h

Ô

×

Ì

É

f

g

h

¼

×

Ì

É

f

g

h

Ø

Ù

Ì

É

Ð

g Ì

f

g

h

È

Ú

Ì

É

Selection.BorderAround LineStyle:=xlNone With Selection.Interior f g h Í È Ê Ë .ColorIndex = 15 f g h Í È h “ .Pattern = 17 .PatternColorIndex = xlAutomatic End With End Sub

11


 Ă&#x201A;

$

P     

Ă&#x192; JÂą Ă&#x2014; Ă&#x152; Ă&#x203A; Ă&#x153; Ă? Ă&#x17E; JÂą







 U h §

Ă?

Ă&#x160;

Ă&#x2C6;

.











'

$



%

&

Â&#x2C6;

Â&#x201C;TĂ&#x160;

Ă&#x2039;

Ă&#x2039;Th

Â&#x201C;



 p q 1Â&#x2C6;Â&#x2DC; Â&#x2122; `2 3 A p q 2Â&#x2C6;BCÂ? JK L MÂ? Ă&#x; Ă  ĂĄ Âą  p q 3Â&#x2C6;m ¢ ÂŁ Âť ÂŹ (# ) W Â&#x2026; I â Ă&#x2039;ĂŁ k Ă&#x20AC; `¢ ÂŁ Ă&#x201D; sä ­ Â&#x153; ¤Â&#x2026;ÂŹ ÂĽ ÂŚ U §  p q 4Â&#x2C6;$ % Ă&#x2014; Ă&#x152; h Â&#x201C;TĂ&#x160; Ă&#x2039;Ă&#x2020;Ă&#x203A; Ă&#x153; Ă&#x2020;Ă? Ă&#x17E; Ă&#x2020;Ă? Ă&#x2C6; h Â&#x201C;TĂ&#x160; Ă&#x2039; p q 5Â&#x2C6;`b c 2 3 A t u  Sub ChangeGraph() ActiveSheet.Rectangles.Add(89.6, 60, 135.2, 74.4).Select JÂą U § ĂĽ With Selection.Border Ă&#x2014; Ă&#x152; ĂĽ .LineStyle = xlContinuous Ă&#x2014; Ă&#x152; h Â&#x201C;ĂĽ .ColorIndex = 7 Ă&#x2014; Ă&#x152; Ă&#x160; Ă&#x2039;ĂĽ .Weight = xlHairline End With Ă&#x203A;

Selection.Shadow = True

Ă&#x153;

ĂĽ

Selection.RoundedCorners = True With Selection.Interior .Pattern = 17 .ColorIndex = 4 .PatternColorIndex = 1 End With End Sub

Ă? JÂą

JÂą

Ă?

Ă&#x2C6;

Ă? h

Ă&#x2C6;

Ă&#x17E;

ĂĽ

ĂĽ Â&#x201C;ĂĽ JÂą

Ă?

Ă&#x2C6;

Ă&#x160;

Ă&#x2039;ĂĽ

12




p

q p

q p

q p

q





















%

&

1ˆBC B3:H4 æ ç  2ˆ`2 3 A 3ˆ ! ¯j/J) /° ” <è (# )  4ˆm ¢ £ » ¬ x (# ) * e â Ëã k Ÿ`é ¢ £ Ô sê w Ó ­ ¤¬ ¥ ¦ U §  13


p

q p

q p

q p

q

5ˆm ë ì ÆXÆY í = = î ï j„{  6ˆm ð ñ ò Ê Ë$ %  7ˆm ¢ £ » ¬ J) ­ r œ  8ˆ`b c 2 3 A

Sub ChangeChart() ActiveSheet.ChartObjects("J)

30").Activate

ActiveChart.ChartWizard Source:=Range(“B3:H4”), _ Gallery:=xl3DColumn, _ J) ¾ > 4 “   &   å Format:=4, _ J) ¾ >   0 å PlotBy:=xlRows, _ CategoryLabels:=1, _ SeriesLabels =1, _ HasLegend:=1, _ Title:=" ó ô õ ö ÷ ø ù ú  à * û _ CategoryTitle:="ý þ ", _ ValueTitle:="ü ", _ ExtraTitle:="" ü

",

ActiveChart.SeriesCollection(1).Select With Selection.Border .Weight = xlThin .LineStyle = xlAutomatic End With With Selection.Interior .ColorIndex = 4 .Pattern = xlSolid End With Windows("Book1").Activate End Sub

14








( 1 4 ; )

*% 2 3 5 *6 < =

&

*

+

,

-

)



.

5

*7

8

9

*

:



/

0

+

15


( Â&#x153;



  +  +

+

,

)

4 5 6 , .- . , .4 5

-

*% Â&#x2021;

&

*

+

,

-

)



.

/

0

+

Â&#x2C6;

.

Â&#x2021;  0 Â&#x2C6;  Â&#x201E;+ , - .

+ , - . Â&#x201E; + , .- . = Â&#x201E;

Âź

Ă&#x2014;



Â&#x201E;

  BC W f g h W X â&#x20AC;&#x153;Welcome Allâ&#x20AC;? Selection.Value = â&#x20AC;&#x153;Welcome Allâ&#x20AC;? BC W f g h W k 0 U §  18 Selection.Font.Size = 18 m  9 Â&#x201C; Â&#x201E;   4 Â&#x201C; >  Aplication.DisplayFullScreen = True

   + , - .  % = + , .- .

+ , - . f g < Ă&#x201D; Ă&#x2014;  Â?   m f g Â? W X g j diffrow1  diffrow1 = ActiveCell.Value +

m

, +

4



%

Â?

5

,

Â&#x153;  4 5 o " #   BC SalesTp (# ) Worksheets(â&#x20AC;&#x153;SalesTpâ&#x20AC;?).Select

1

2

3 16


VBA Ă° Ăą  0 7  Â&#x2C6;   0  k l  0 



0 











(   ) Boolean(  )

2  

True  False

Integer( )

2  

-32768  32767

Long(  )

4  

-2147483648  2147483647

Single (    )

4  

-3.402823E38  

!

-1.401298E-45 1.401298E-45 

Currency (" # )$ % &  

8  

3.402823E38 -922,337,203,685,477.5808 

Date ( ' ( ) * +)

8  

922,337,203,685,477.5807 January 1,100  December 31,999

  Dim A As Boolean Dim B As Integer Dim C As Single k

l



0 











(   ) String ,

-



0 .  65535



1  

Byte

0  255

  Dim S As String Dim D As Byte

4

5

*6

5

*7

8

9

*

:

 17


%

P 9 o f g   ^  & f g 8 P  Â&#x201E;Â&#x153;  + ,  Â&#x153;  MyFontSize = Range(â&#x20AC;&#x153;A1â&#x20AC;?) .Font.Size f g   - . 

9



i

jĂ°

Ăą

Â&#x2026;

ÂŹ



 Â&#x2021;  MyCalcResult = Sum(â&#x20AC;&#x153;A1:A5â&#x20AC;?) f g   ^   7  YourWealth = InputBox â&#x20AC;&#x153;How much money you have?â&#x20AC;? f g 8 9  i jĂ° Ăą

%

 Â&#x2019;  Set MyData = Range(â&#x20AC;&#x153;A1:C10â&#x20AC;?) FÂ&#x201E; MyData + ,  A1:C10 Set MyWork = Worksheets(â&#x20AC;&#x153;Sheet1â&#x20AC;?) FÂ&#x201E; MyWork + , Sheet1

  ĂŞ    { |  Â&#x2C6; ĂŚ ç % < Â? 8 9 Â&#x2026;< Ă&#x2DC; Ă&#x2122;  Dim & Static   Sub Mywork1() Dim Jobno As Integer JobNo = 111 + JbNo . . . End Sub

sk





! 9 % " Â&#x153; Ă&#x161; W v 6 #  Â? v 6 $ 8 9 Â&#x2026;<#  Ă&#x2DC; Ă&#x2122; P



Dim 18


& Public sk     Public JobNo As integer

Sub MyWork1() . . . End Sub Sub MyWork2() . . . End Sub Sub MyWork3() . . . End Sub &

% 5  Const & & Const & 



= ) > Â&#x201C;





As  0

= ) > Â&#x201C;

  Const Pi = 3.14159 Const StarDate = #5/15/94# Private Const InterestRate As Double = 0.9513 Public Const Ownername = â&#x20AC;&#x153;' U ÂŞ â&#x20AC;?

19


(

)

(

Â&#x20AC;

T)

>

Â&#x20AC;

>

Â&#x201C;

) > m Ă° Ăą # ) ( * &¨   Â&#x201C; +Â&#x153;  , % T( Â&#x20AC; e  

 ( *

^ * / \ Mod + -



-



Â&#x20AC; . Ă&#x2018; F / 0 C1 C2 Ă&#x17D; 3

%

Â&#x2C6;A=11 B=2 5

A^B A*B A/B A\B A Mod B A+B A-B

121 22 5.5 5 1 13 9

4 } ( Â&#x20AC; 5  Ă&#x201E; k ( Â&#x20AC; 4 } ( Â&#x20AC; 6 â&#x20AC;?&â&#x20AC;?Tâ&#x20AC;?+â&#x20AC;?Â&#x2021;  Â&#x153;   A1 f g â&#x20AC;?Hallo!â&#x20AC;?Â&#x2026;A2 f g â&#x20AC;?How Are You?â&#x20AC;?Â&#x2026; A3 i j! Â&#x201C;â&#x20AC;?=A1&A2â&#x20AC;?+ž > â&#x20AC;?Hallo! How Are You?â&#x20AC;?â&#x20AC;?  Â&#x2021;  6 Â? A11 f g  Â&#x20AC; >   h

ž

>

â&#x20AC;?Hi Â&#x2026;Hallo! How Are Youâ&#x20AC;? â&#x20AC;?+â&#x20AC;?(

Sub OpPlusdemo() Sheets(â&#x20AC;&#x153;Sheetâ&#x20AC;?).Activate tor1 = â&#x20AC;&#x153;HiÂ&#x2026;â&#x20AC;? tor2 = â&#x20AC;&#x153;Hallo! â&#x20AC;? tor3 = â&#x20AC;&#x153;How Are Youâ&#x20AC;? tor4 = tor1 + tor2 + tor3 End Sub

7 Âł ( Â&#x20AC; A B *

20


And Eqv* Imp* Or Xor* Not A % 5 : A( € Bt u 0 1 1 0 0 1 0 0 1 1 1 1 0 0 0 1 1 0 1 1 1 0 0 0



0 0 1 1

0 1 0 1

8 9 ( *

< <= > >= = <>

€ . §

: §

: U

: U

:

: ê

Ñ

:

:

%

:

5

A<B A<=B A>B A>=B A=B A<>B

; P

<

=

ˆ 21


; < = > ? @ A

;

Sub AAAA …. …. No If …. … Yes … Else … … … EndIf … … Goto Line1 … … … Line1ˆ … … … End Sub

<

=

Sub BBBB …. …. …. …. …. …. Do …. …. …. …. …. …. Loop …. …. …. …. …. …. End Sub

22


Sub CCCC() â&#x20AC;Ś. â&#x20AC;Ś. Proc1 â&#x20AC;Ś. â&#x20AC;Ś. â&#x20AC;Ś. Call Proc2 â&#x20AC;Ś â&#x20AC;Ś â&#x20AC;Ś End Sub Sub Proc2() â&#x20AC;Ś. â&#x20AC;Ś. End Sub

Sub DDDD() â&#x20AC;Ś. â&#x20AC;Ś. Exit Sub â&#x20AC;Ś. â&#x20AC;Ś. â&#x20AC;Ś. Proc3 â&#x20AC;Ś. â&#x20AC;Ś. â&#x20AC;Ś. End Sub Sub Proc1() â&#x20AC;Ś. â&#x20AC;Ś. End Sub

Sub Proc3() â&#x20AC;Ś. â&#x20AC;Ś. End Exit Sub â&#x20AC;Ś. â&#x20AC;Ś. End Sub

;

[ B , BC GoTo % 5  GoTo Line . . LineÂ&#x2C6; . .   Sub demo1() 23


Static counta Range(â&#x20AC;&#x153;A1â&#x20AC;?).Value = â&#x20AC;&#x153;This is Demo1â&#x20AC;? counta = counta + 1 If counta = 1 Then Goto line1 Else counta = counta - 2 Goto line2 End If line1Â&#x2C6; Range(â&#x20AC;&#x153;A3â&#x20AC;?).ClearContents Range(â&#x20AC;&#x153;A2â&#x20AC;?).Value = â&#x20AC;&#x153;counta = 1â&#x20AC;? Exit Sub line2Â&#x2C6; Range(â&#x20AC;&#x153;A2â&#x20AC;?).ClearContents Range(â&#x20AC;&#x153;A3â&#x20AC;?).Value = â&#x20AC;&#x153;counta = 2â&#x20AC;? End Sub GoSubâ&#x20AC;ŚReturn % 5  GoSub line â&#x20AC;Ś lineÂ&#x2C6; â&#x20AC;Ś Return   Sub demo2() A = 100 GoSub demo2rountine Range(â&#x20AC;&#x153;A5â&#x20AC;?).Value = A Exit Sub demo2rountineÂ&#x2C6; A = sqr(A) * A Return End Sub

6 B , BC 24


Â&#x2039; BC Ifâ&#x20AC;ŚThen  Ă&#x161; _Â&#x153; @   Sub demo3() A = 100 â&#x20AC;&#x2DC;m A = 10000Â&#x2026;+ A7 ? If A>100 Then A = sqr(A) Else A = sqr(A) * 2 End If Range(â&#x20AC;&#x153;A7â&#x20AC;?).Value = A End Sub

100

D E BC Ifâ&#x20AC;ŚThenâ&#x20AC;ŚElse Select Case   Sub ArOverdue() Ask3 = InputBox(â&#x20AC;&#x153; F BC Â&#x2C6;1Ă&#x2020;G H 30 IÂ&#x2026;2Ă&#x2020;G H 60 IÂ&#x2026;3Ă&#x2020;G H 90 Iâ&#x20AC;?,,1) If Ask3=â&#x20AC;?â&#x20AC;? Then Exit Sub End If Select case Ask3 Case 1 OverDue30 Case2 OverDue60 Case 3 OverDue90 End Select End Sub Onâ&#x20AC;ŚGoSubÂ&#x2026;Onâ&#x20AC;ŚGoTO

<

= 25


Doâ&#x20AC;ŚLoop   Sub demo4() Do countmn = countmn + 1 Range(â&#x20AC;&#x153;Bâ&#x20AC;? & countmn).value = countmn If countmn > 6 Then Exit Do End If Loop End Sub For Next   Sub salaryCalc() Sheets(â&#x20AC;&#x153;sheet1â&#x20AC;?).Activate For I=1 To 6 Range(â&#x20AC;&#x153;Aâ&#x20AC;? & I+8).Value = ThisNum(111) Next End Sub Whileâ&#x20AC;ŚWend   Sub demo5() While countmn < 6 countmn = countmn + 1 Range(â&#x20AC;&#x153;Bâ&#x20AC;? & countmn).value = countmn Wend End Sub >

?

Call     Sub month1() Call adddate(1,1,â&#x20AC;?; J K L â&#x20AC;?) Call adddate(1,11,â&#x20AC;?M 5 N â&#x20AC;?) Call adddate(1,15,â&#x20AC;?O P N â&#x20AC;?) 26


Call adddate(1,23,”¨ , I”) End Sub    Sub month1() adddate 1,1,”; adddate 1,11,”M adddate 1,15,”O adddate 1,23,”¨ End Sub >

J

K

L

” P N ” , I” 5

N

?

ExitˆExit Do…Exit For…Exit Function…exit Sub EndˆEnd…End Function…End If…End Select…End Sub

27






 > A ?

@







B

C



D

:

> 8

9

¢

£

<J)

r

BTH8

? J)

@



Q





)

 œ

$

E

 „Þ

RS

"

 28


p

q

œ

T

J 4-1 i

ñ

J 4-1 p

p

q

q

J 4-2 BCð

‡

T

ñ

7

J 4-2 BCD E ) * ¯j/J) /° FG …aH I à  K L M ”

(#

)

*



29


Y

„[

\

^

`œ

p

`A

J 4-3 BCð Y

„J)



0

^

`œ

p

ñ

o

U

`A

J 4-4 BCJ) Y

„J)

h

“^

`œ

p

„[

\

^

`œ

p

0

`A

J 4-5 BCJ)

Y



h

“

`A 30


Y

J 4-6 J)

„ÎjJ)

=

V

Æí

=

W

=

J 4-7 ÎjJ)

V

=

^





V

`d

Æí

=

e

W

`A

=

V

31


J 4-8 d p p p

q

’ q

X q

Y

BCD 8 9 ¢ m ¢ £ C‚ J) h

p

q

q

[

[

J

(: //2 3 ;  £ 4 ~ r BJ) ‡  » x J) * …`¢ £ ¼ s…TH ½ Z D E ) …B N ¡ µ J) FG …aH I J 4-9 „‚ N ¡ µ “K L M E

)

J 4-9

p

e

*

„‚

N

¡

µ

J)

h

“K

L

_ „‚ N ¡ µ J) h “K L MB o \ ] Ô ¼ ^ S Þ R 30 R…`Y BJ) P ­ ® 4 œ  _ ^ `b c A

M

& „AŸ9 ¢

A… £ r

32


p

q

`

BC Module1 (# )

…aH

J 4-10

I

“#



)



/0123

J 4-10

“ˆ

p q a ' $

Sub Record1() Dim Angle As Integer

“#



)

'b $ % Þ R- : " 1

c Î œ ActiveSheet.ChartObjects("J) 1").Activate Angle = (ActiveChart.Rotation + 10) Mod 360 With ActiveChart .Elevation = 15  $  ! å .Perspective = 30 .Rotation = Angle .RightAngleAxes = True .HeightPercent = 100 .AutoScaling = True End With ActiveWindow.Visible = False Windows("Book1").Activate End Sub c

Î

œ

33


p

q

ã

m

¢ £ » ¬ J) `¼ sœ …BCF„FG …a H I J 4-11 F„K L M…ŸBC Record1  …Ÿ`Y „A

J 4-11 F„K p

q

ã

œ

m

¢

£

»

¬

J)



L !

M …ad

e



34


A p

q

œ

T

J 4-12 i

B

C



D

p

‡

q

q

7

T

J 4-13 BCð

BC(:





$

E

ñ

J 4-12 i p

:

ñ

ñ

J 4-13 BCð ñ /2 3 /2 3

;

 35


p

q

BCD E ) * ¯j/J) /° FG …aH I à  K L M Y „[ \ ^ `œ p `A ’

J 4-14 BCð Y

„J)



0

^

`œ

p

ñ

o

„J)

h

“^

`œ

(#

)

*



U

`A

J 4-15 BCJ) Y

”

p



0

`A

J 4-16 BCJ) h

“

36


„[

Y

Y

\

^

„ÎjJ)

`œ

=

V

p

Æí

`A

J 4-17 J) 

=

`d

W

=

J 4-18 ÎjJ)

V

=

^

V

Æí



=

e

W

`A

=

V

37


J 4-19 d p

X

BC Module1 (#

q

)

q

Y q

[

J

…aH

J 4-20

p p

e

“#

J 4-20



I

“#



)



)

BC‚ N /(: @ / JFG  BC J(: @    ¡ `AFG …¤ ’ A… d H I F„K L A…Ÿ`Ce A 

`

38


J 4-21 Îj’ p

q

`

BC Module1 (# )

`A

Îj’



J 4-22 Îj’ 



(J 4-21)ˆ

39


p

q

a

BC Module1 (# JÂ&#x2C6; )

Â&#x2026;m

f

f

2

3



Â&#x201C;Ă&#x201A;

$



45678 45@

9:;< =>?

A0@B

A0@B

p

q

ĂŁ

m

¢ ÂŁ Âť ÂŹ `A`Âź sÂ&#x153; Â&#x2026;BCFÂ&#x201E;FG Â&#x2026;a H I J 4-11 FÂ&#x201E;K L MÂ&#x2026;Â&#x;g BC Button4Â&#x2026; Button5Â&#x2026;Button6Â&#x2026;Button7 Â&#x2026;Â&#x;`Y Â&#x201E;A

J 4-23 FÂ&#x201E;K L

M

40


p

q

ã

œ

m ¢ £ » ¬ `A`Ô sœ  ! …ad J 4-25ÆJ 4-26ÆJ 4-27

e

J 4-24Æ

J 4-24

41


J 4-25

J 4-26

J 4-27

42








 Access F  Access 1

G

1

2

H



I

J

1

2

2

H

K



1

2

D

:

L

8



K

43


 Access F 



1

2

H



I

J

1

2

U

h ‡ Ú o . ˆ  < Access   ¡ ð ñ i  _ Access i jð ñ

< Access  

p

p

G

ð

ñ

i

œ

ˆj " Access ð ñ i…BC(# @  k l / “ /Microsoft Access…aH I J 5-1 Microsoft Access K L M

q

q

¡

‡

J 5-1 Microsoft Access K L M ˆ<K L M   ¡ œ  ; ð ñ i8 9 BC• ð ñ i…Ÿ`Y „A…J 5-2 –

44


J 5-2

p

7

ˆ`m Y „A] ^ …aH J 5-3 k j L M…<n o   i jn  ^ …`Y   ¡ œ  ; ð ñ i

q

J 5-3 k p

q

’

j

;

ð

ñ

iK

ˆ`m Y „A] ^ …aH Bƒ `; c A

L

;

ð ñ iK „A…a

M J 5-4…<ð ñ

)



45


p

X

ˆ`m ; c A] ^ …aH J 5-5 ; M…B  ‚ N Ÿ`Y „A

q

J 5-5 ; p

q

Y

ˆd

e

p

q

X

aH

c I

ð

ñ

)

K

L

c

ð

ñ

)

K

L

M

J 5-6

46


J 5-6

p

q

[

ˆ<P Ô × ò {  ò {    ð ñ 0 1  ò { U §  š › 6 ð ñ  p  

i

j¼ × …J 5-7 Name Ä k 10  (ê E º )

47


CDEF@G HIJKLM8

p

p

`

q

q

J 5-7 ˆ<P Ô × ò {  i j¼ × ò {    Year ð ñ 0 1  k ò { U §  { K 

a

…J 5-8

J 5-8 ˆ<P Ô × ò {  i j¼ × …J 5-9 ò {    School ð ñ 0 1  Ä k ò { U §  10 48


p

q

ã

J 5-9 ˆi jd ¹ ] ^ …m  # “N O q …H I J 5-10 Ÿ`Y „A…H I J 5-11 r g ; n K L M… `Y „A…H I J 5-12…ad e   ¡ œ  ð ñ i

J 5-10

J 5-11

49


J 5-12

< Access i

p

ñ

œ

<J 5-12 

q

`k

j

A…aH

I

J 5-13

J 5-13 p

q

‡

m

)

h

ð

ñ

i

j…t

u

J 5-14 50


Name s 7 u ’ ' `

Year 21 25 22

School  è U t  è U t ð (v  v U t

J 5-14 p

q

7

m

i

ñ

N

O

q

…ad

e

i

ñ



51


Access 1 p

q

Â&#x153;



2

H

K



1

! ÂŻj/) 5-15 Â&#x2022; Â&#x2013; #  ) 

q

Â&#x2021;

 {

!

(: /w y K L M

J 5-16 w

x

Â&#x2013; {

x

D

:

/#

J 5-15 Â&#x2022; p

2

#

{

y





K

)

8

FG

 Â&#x2026;a

K I

J

)

FG

y

L

L

Â&#x2026;a

I

J 5-16 w x

M 52


p

7

<J 5-16 w x { y K L M B Microsoft DAO 3.5 Object Library ƒž J 5-17…Ÿ`Y „A

q

J 5-17 p

q

’

< Module1 (# )

W

i

j@

“z



Sub ReadDatabase() Dim myDatabase As Database Dim myRecordset As Recordset Set myDatabase = OpenDatabase("C:\My Documents\db1") Set myRecordset = myDatabase.OpenRecordset("{ (ð ñ ") Range("A1").Value = "|  " Range("B1").Value = "J H" Range("C1").Value = "t } " RecordNo = 2 While Not myRecordset.EOF PersonName = myRecordset![Name] PersonYear = myRecordset![Year] PersonSchool = myRecordset![School] Range("A" & RecordNo).Value = PersonName Range("B" & RecordNo).Value = PersonYear Range("C" & RecordNo).Value = PersonSchool RecordNo = RecordNo + 1 myRecordset.MoveNext 53


Wend myRecordset.Close myDatabase.Close End Sub p

q

X

~

 ¬ Sheet1 (# ReadDatabase o !

)

… …t

! u

(: /…B J 5-18

J 5-18

54


Microsoft Excel Macro Tutorial  

tuto in chinese

Advertisement
Read more
Read more
Similar to
Popular now
Just for you