Профессиональное на VBA в Excel 2002excelvba.ru/UsefulBooks/book4.pdf ·...

786

Transcript of Профессиональное на VBA в Excel 2002excelvba.ru/UsefulBooks/book4.pdf ·...

  • VBA Excel 2 0 0 2

  • Excel 2002 PowerProgrammingwith VBA

    John Walkenbach

    M&T BooksAn imprint of Wiley Publishing, Inc.

  • VBA Excel 2002

    - 2003

  • 32.973.26-018.2.7562

    681.3.07

    ""

    . ..

    ..

    .. , .. , .. , ..

    ..

    "" :[email protected], hup://www.diatektika.com

    , .

    62 VBA Excel 2002. : . .

    . : '"", 2003. 784 . : . . . .

    ISBN 5-8459-0541-9 (.)

    Excel , , . , VBA (, ). , Excel, -. , - . , - -. Excel. , . . ?

    32.973.26-018.2.75

    - .

    , , - , Wiley Publishing. Inc.

    Copyright 2003 by Dialektika Computer Publishing.

    Original English language edition Copyright 2003 by Wiley Publishing, Inc.

    All rights reserved including the right of reproduction in whole or in part in any form. This translationpublished by arrangement with Wiley Publishing, Inc.

    ISBN 5-8459-0541-9 (.) - "", 2003ISBN 0-7645-4799-2 (.) Wiley Publishing, Inc., 2003

  • I. EXCEL 31

    1. Excel 2002: 32

    2. Excel 45

    3. 63

    4. Excel 82

    II. EXCEL 97

    5. 98

    . 111

    III. VISUAL BASIC FOR APPLICATIONS 129

    7. Visual Basic for Applications 130

    8. VBA 175

    9. VBA 209

    10. 240

    11. VBA 267

    IV. 317

    12. 318

    13. 335

    14. 364

    15. UserForm 387

  • V. 417

    16. Excel VBA 418

    17. 440

    18. 453

    19. Excel 497

    20. 525

    21. 542

    VI. 563

    22. 564

    23. 591

    24. 619

    25. 635

    VII. 64S

    26. 646

    27. VBA 658

    28. Visual Basic 677

    29. 695

    30. Excel 706

    . , Excel 738

    . VBA 743

    . VBA 751

    . ANSI 755

    . Web- 763

    775

  • 24

    25

    25 25 26, 26

    , 26, 27

    27 28

    I 28 II 28 III 28 IV 28 V 28 VI 28 VI] 29

    29 29 29

    30

    I. EXCEL 31

    1. Excel 2002: 32

    32 VisiCalc 32Lotus 1-2-3 33Quattro Pro 36Microsoft Excel 38

    41 Excel 43 Excel Microsoft 44 44

    2. Excel 45

    ... 45 46

    47

  • 48 XLM 48 Excel 5/95 48

    Excel 48 49 49 50 51 51

    52 52 53 53

    53 54

    54 55 55 56 57 57 58

    59 59

    Internet 60 60

    60 60 60Analysis ToolPack 60 61 61 61

    61 62 62

    3. 63 63 64 65

    65 RIC1 66 67

    68 68 68 69 70 70 70 71 72

    8

  • 72 73

    74 74 75

    75 75 76 77

    77 78 1900 78

    79 81

    4. Excel 82

    Excel 82 Excel 84 85

    Lotus 1-2-3 85 Quaitro Pro 86 86 86 87

    , Excel 87 XLS 87 88 88 89 89

    Excel HTML 90 ? 90 HTML- 91 1? 92

    Excel 93 93 Excel 95

    96

    II. EXCEL 97

    5. 98 98 99

    ? 100 101 101 102

    104 105

    " " 106 " " 106 106

    9

  • -"" 107- 107 108 108 "-" 109 109 109 " " 110

    6. 111 112 , 113 115

    116 ActiveX 116 117 119 120 120

    121 121 122 124 , 124 125 126

    126 Excel, 127, 127 127 127 128

    128

    III. VISUAL BASIC FOR APPLICATIONS 129

    7. Visual Basic for Applications 130

    BASIC 130 VBA 131

    131 VBA XLM 131 VBA Lotus 132 VBA LotusScript 132

    VBA 132 Visual Basic 135

    VBE 135 VBE 136

    Project Explorer 137 VBA 138 VBA 138 138

    139

    10

  • 139 VBA 140 VBA 141

    VBE 146 Editor 146 Editor Format 148 General 149 Docking 149

    150 150 ? 151 154 155

    156 157 157 158

    158 158 159

    Comment: 160 Comment 160 Comment I6I Comment 162 Comments 162 Comment 163, Comment 163 165 Comment 165

    Application 166 Range 167

    Range 167 Cells 168 Offset 170

    171 , 171 . 172

    174

    8. VBA 175 VBA. 175 176, 178

    179 181 133 185 187 187

    188 190

    190 190

    11

  • 191 . 192 192 194

    With-End With 195 For Each-Next 195

    197 GoTo 197 If-Then 198 Select Case 201 203

    208

    9. VBA 209 209 210

    211 211

    Run^RunSub/UserForm 212 212 213 214 215 2 ] 9 219 220 Immediate 220

    221 224

    224 225

    227 227 227 228 228 229 229 230 231 232 234 235 238 238

    239

    10. 240 : 240 240 241

    241 242

    12

  • VBA 242 242

    243 244 245 245

    247 247

    247 248 249 251 251 252 VBA, 253, 255 256

    Excel 257 259 260

    260 261

    262 Windows API ' 263

    Windows API 263 Windows 264 265 API 265

    266

    11. VBA 267

    268 268 269 269 270 271 273 , 274 275 275 276 278 , 278 279 230 281 282 Variant 283 283 284

    285 286 286

    13

  • 286 2S7

    VBA 288 Boolean 288 289 289 290 291 293

    , VBA 294 FileExists 294 FileNameOnly 294 PathExists 295 RangeNameExists 295 SheetExists 295 WorkbookIsOpen 296 296

    Excel 298 298 299 299 300 300 301 ? 302 - 303 304 SHEETOFFSET: 1 305 SHEETOFFSET: 2 305 306 307 309

    Windows API 310 310 311 312 312 314

    316

    IV. 317

    12. 318

    ... 318 319

    inputBox VBA 319 InputBox Excel 320

    VBA MsgBox 321 Excel GetOpenFilename 325 Excel GetSaveAsFilename 328 328

    Windows API 328 FileDialog 330

    14

  • Excel 331 Dialogs 331 332 333 333

    334

    13. 335

    Excel 335

    UserForm 336

    336

    337

    337CheckBox 337ComboBox 337CommandButton 338Frame 338Image 338Label 3*38ListBox 338MultiPage 338OptionButton 339RefEdit 339ScrollBar 339SpinButton 339TabStrip 339TextBox 339ToggleButton 339

    340 342

    Properties 342 343 343 343

    345 345 346 347

    347 348 350 350 351 352! 353

    UserForm 353 353 UserForm 354: SpinButton 354 SpinButton TextBox 356

    358

    Toolbox 359 359

    15

  • 360 360 ActiveX 361

    "" 362 362 363

    14. 364

    UserForm 364 CommandButton 364 ListBox. 365

    366 367 368 369 370 ListBox 372

    ListBox 372 ListBox 373 376 376 ListBox 377 ListBox 378 ListBox 379 ListBox. 380 ListBox 382 ListBox 384

    MultiPage 385 386

    15. UserForm 387

    387 388 MultiPage 390 MultiPage 392

    393 MultiPage 393 394 394 396 397 398

    MsgBox 398 MyMsgBox 399 400 MyMsgBox 401

    401 404

    404 406

    406 407

    16

  • 1: 408 2: OWC ChanSpace 409

    4-12 415

    415 416 416

    416

    V. 417

    16. Excel VBA 418

    Excel 418 VBA 419 419 : 420

    420 Text Tools 420 421 Text Tools 421 FormMain 422 modMain 423 ApplyButton_Click 426 427 434 ShowStats 435 437 438 438 Text Tools 439

    439

    17. 440

    440 441 442 442

    443 443 445 445 446

    447 448 451 452

    18. 453

    453 453 454

    455 456

    17

  • 457 VBA 458

    458 460 460 ChartObject 461 461 462 ChartQbject 463

    464 464 , 466 ComboBox 467 ];: 468 473 476 478

    481 Chart 481 484 Chart 485

    487 487 "" 487 488 490 491 492 492 "" 494 495

    496

    19. Excel 497

    Excel 498 498

    498 499 499 501 , 502

    Workbook 503 Open . 504 Activate 504 SheetActivate 505 NewSheet 505 BeforeSave 505 Deactivate 506 BeforePrint 506 BeforeClose 507

    Worksheet 509 Change 509 510 SeleclionChange 514

    18

  • BeforeRightClick 5 ] 5 Chart 515 Application 516

    Application . 518 518 Application 519

    UserForm 520, 521

    OnTime 522 OnKey 523

    524

    20. 525 525 528 529 530

    530 530 533 Word Excel 533 Excel 536

    ADO 537 SendKeys 540 541

    21. 542 542

    542 543

    Excel 544 545 546

    546 546 547 547 548 549 549

    XLA XLS 550 550 550 550 551 VBA 551

    VBA 553 Addlns 553 Addln 555 Addln 557

    558 558 559

    19

  • , 559 559 561 Excel 561

    562

    VI. 563

    22. 564 564 565 Excel 565

    565 566

    567 567 570

    CommandBars 572 572 CommandBar 573 574 574 575 575 580 581 581 582 583 583

    590

    23. 591

    Excel 591 Excel 592

    592 593 594 594

    VBA 595 595 596 598 599 602 604

    604 604 605 606

    609 , 611 612

    20

  • 614 615 615 615 616 616

    618

    24. 619

    Excel 619 , Excel 621

    621 622 623 624 Office 626

    WinHelp System HTML Help System 629WinHelp 629HTML Help 630

    631 WinHelp HTML Help 633

    Help 633 633 634

    634

    25. 635

    , 635 635

    636 637 638 642

    642 643 644

    VII. 645

    26. 646

    646 647 Excel 648 649, Windows API 649 650 651

    653 VBA 654 "" 654 654

    21

  • 656 657

    27. VBA 658

    658 VBA 659 FileSearch 661 , 663 FileSystemObject 663

    665 666 666 667 667 667 668

    668 668 669 670 Excel 671 671 256 672 HTML 674

    676

    28. Visual Basic 677

    IDE 677 IDE 678

    VBProjects 679 680 681 VBA VB 683 UserForm 685

    UserForm 686 100 CommandButton 687

    UserForm 688 689

    -, 690 694

    29. 695 695: NumLock 696

    696 VBA 697 NumLock 698

    698 698 698 700 700

    : CSVFile 701

    22

  • 701 701 702 CSVFileClass 704

    705

    30. Excel 706

    Excel 707 Visual Basic 711 714 718, , 720 728 733 CommandBar 735

    . , Excel 738

    Microsoft 738 738Microsoft Knowledge Base 739 Microsoft Excel 739 Microsoft Office 739

    739 , 740 Microsoft 740 741

    Web- 742Spreadsheet Page 742Web- (Chip Pearson), Excel 742Web- (Stephen Bullen), Excel 742 , 742

    . VBA 743

    . VBA 751

    . ANSI 755

    . Web- 763

    763 763Power Utility 773

    Power Utility 773Sound-Proof 2000 773

    Sound-Proof 2000 774

    775

    23

  • (John Walkenbach) , ; JWalk and Associates, Inc. - , - - . 30 300 , - . , PCWorld, InfoWorld, PC Magazine, Windows PC/Computing. The Spreadsheet Page Web- w w w . j - w a l k . c o m / s s / . PowerUtility Pak, Microsoft.

    : - .

    24

  • VBA Excel 2002! , , , , Excel , - , .

    Excel . ,

    . , VBA ( , ). - , Excel, . , , . , -.

    Excel. -, , , - ( ) , . -, Excel , . . ?

    Excel. -

    , - .

    Excel 2002 "" , - , , .

    Excel 2002. ( ) Excel. .

    , Excel. , - . , :

    , , ..;

    ;

    ;

    Excel;

    25

  • Excel;

    ;

    Windows, , , .

    , , , , . , , . - , Excel 2002, 2.

    Excel. ,

    Excel 2002, - Excel 2000 Excel 97. Excel, . , , , Excel Macintosh. , - .

    , Windows, Pentium /4 . Excel , .

    (800x600 , 1 024x768 , 1 1 024 " "). , 640x480.

    , , , -

    , .

    , . , -

    .

    , , , , "

    =(2:50) 51". -

    . , .

    =((1:8)+(1:8))/25

    VBA VBA, -

    . ; - . ,

    26

  • , . , -, , .

    , VBA : , - . , . , .If R i g h t ( A c t i v e C e l l , 1) = " ! " Then A c t i v e C e l l

    = L e f t ( A c t i v e C e l l , L e n ( A c t i v e C e l l ) - 1)

    , , , , - .

    , Excel -

    , , " 2 0 ". , , - VBA : " - G e t T o t a l s " . , , - , .

    , , , , , .

    "" : "", "", " ", "" ..

    .

    , .

    , Excel 2002. - , Excel, .

    , , , .

    - , , , .

    , , - , .

    , , .

    27

  • . -

    .

    I . 1

    , Excel . 2 Excel 2002 - , Excel. 3, -, , . 4 - , Excel.

    II . 5

    . 6, , .

    III 7 11. VBA.

    VBA, - VBA. 11 VBA .

    IV (-

    UserForm). 12 - . - , , 13. - 14 15 , .

    V ,

    . , VBA . 19 , -, , . 20 (, , Word). V 21 .

    VI ,

    . 22 23 -

    28

  • . 24 . 25 , , .

    VII , .

    26. 27 VBA . 28, , - VBA Visual Basic, . 29 . , - Excel.

    .

    Internet, Excel. VBA ( ). VBA - , , ANSI. -, , Web- - "" ( h t t p : / / w w w . d i a l e k t i k a . c o m ) .

    , .

    , . , . , "" , , " ". , - .

    , . -

    , , Web- -. , , . , - . , , - , " " " 90 000 ".

    , , - . . , - . , - .

    , Web- ( h t t p : //vww. j - w a l k . c o m / s s / ) , , Excel.

    29

  • -, , . , .

    , Excel. , . .

    , , (Susan Christophersen), . (Bill Manville), . , .

    , (Kathlyn), .

    (John Walkenbach)

    -,

    30

  • Excel

    - Excel - . 1 , , Excel . 2 - Excel . 3 , . 4 , - Excel , -.

  • Excel 2002:

    , Excel 2002, - , - - Microsoft. , - , - . , . , "" - "", .

    . , ,, , , - . - , - .

    VisiCalc VisiCalc

    () Bricklin) - (Bob Frarikston) 1978 , . VisiCalc - Apple II , . (, Apple II -.) VisiCalc , , . VisiCalc ,

  • Apple II , . VisiCalc , Apple II .

    ; - /. Sorcitn SuperCalc - , .

    1981 IB PC, - , VisiCorp VisiCalc . Sorcin SuperCalc, - PC.

    VisiCalc, SuperCalc ., , , , .. . , - . , .

    Lotus 1-2-3 VisiCalc, ,

    , , . (Mitch Kapor) (JonathanSachs), - . , The Wall StreetJournal Lotus i-2-3, . - , -. 1983 Lotus Developmen Corporation, . 495 (, ), VisiCalc, .

    Lotus 1-2-3 VisiCalc SuperCalc - , , 16- IBM PC AT. , Lotus 1-2-3 - DOS , - , -. , "" . , , - Lotus 1-2-3 . , - . -, . , Lotus 1-2-3 - .

    Lotus 1-2-3 , . (1) (2) (3), . - , ", 1, 2, 3"?

    Lotus , Lotus 1-2-3 1983 1. Lotus

    /. Excel 33

  • . 19S5 1 2, 2.01, . 2, , (add-ins) , , . , - 2 , , - . - , .

    , Lotus 1-2-3 - , , , . - Twin Mosaic Software VP Plannet Paperback Software. , ( " " Lotus 1-2-3)Lotus Paperback Software . , Lotus, Paperback.

    1989 Lotus DOS- OS/2- 3 Lotus 1-2-3. , , ; " " . , . Boeing Calc, -, SuperCalc 5 CubeCalc.

    3 Lotus 1-2-3 ,, , . , , , - . , : - .

    3 , 80286 - 1 "" 1989 . Lotus , . 3 , 2.01 (- Lotus 1-2-3 2.2)). , 3 2. Lotus , : , , , .

    , 2.2 Lotus 1-2-3 , - . All ways, ''" , -, . , - WYSIWYG (What You See Is What You Get , )., , . , , Lotus 1-2-3 -, , , - .

    34 1. Excel 2002:

  • -, . , - - .

    , , , Microsoft Office XP " -". , - " ". - , - .

    , Microsoft -, , . (Lotus 1-2-3 WordPerfect), . , , , .

    , . -, - . , -, Microsoft. ? . , ? , . ? . "" - ? ,

    1990 Microsoft Windows 3,0. , , , - . ,, Lotus , Windows , - , - Windows. Lotus 1-2-3 for Windows 1991 . , , , . Windows . Excel, "" Windows -, Windows- ( - ). Lotus, 1993 : Lotus 1-2-3 4 Windows. . 5 Windows, 1994 .

    Lotus 4.0 DOS (Lotus 1-2-3 Release 4.0for DOS). ( ) , - Windows. ; - 3.4. Windows - , , , Lotus 1-2-3 DOS, .

    Lotus ( - Notes). 1995 IBM Lotus Development Corpora-tion. Lotus 1-2-3, , , , " , ". Excel - , a Lotus 1-2-3 .

    Lotus 1-2-3 , LotusScript -, VBA (. 1.1). , . , Lotus, - Microsoft VBA.

    I. Excel

  • . I.I. Lotus i-2- LotusScript , VBA

    Quattro Pro (, ,

    ) Borland International. 1994 Novell WordPerfect International Borland , . 1996 WordPerfect QuattroPro Cord Corporation.

    Borland 1987 , , - Quattro. , , Lotus 1-2-3, - , , . , . , , - Lotus 1-2-3, , , , Lotus 1-2-3.

    1989 Borland Quattro Pro , - , Quattro, Lotus 1-2-3 . , Quattro Pro , , . , - (Graphical User Interface GUI). : Quattro Pro - Surpass, Borland.

    1990 2.0 Quattro Pro (Quattro Pro Version 2.0), - Paradox Borland. Quattro Pro 3.0,

    1. Excel 2002:

  • -. 1992 4? "

    1' , . 5, 1994 , , -, (.. ).

    Lotus, Borland Windows. , - 1992 Quattro Pro for Windows , Windows-, -: Excel 4.0 Lotus 1-2-3 1.1 Windows. , Quattro Pro Windows , UI Builder ( - ). - .

    , Lotus Borland. Lotus , Borland Quattro Pro 1-2-3 , Lotus 1-2-3. , 1994 , - , Quattro Pro , Lotus 1-2-3 ( - ). , , .

    . 1.2. Quattro Pro Corel

    Borland 5 Quattro Pro Windows. , Novell Borland , - , 5 6 (. 1.2).

    I. Excel 37

  • Quattro Pro , WordPerfectOffice 2000. , - 1 18 278 (, Ex-cel ). Quattro Pro - .

    Quattro Pro -. Excel 5.

    Microsoft Excel . , ' Microsoft

    1980- . Microsoft : MultiPlan, - , Excel 2002, - .

    , 1982 Microsoft MultiPlan . , /, MultiPlan - , , Apple IT, Apple , XENIX MS DOS.

    MultiPlan . , . , Lotus 1-2-3.

    . 1.3. Excel 2.1 Windows, , Excel ? ( Microsoft)

    38 1. Excel 2002:

  • MultiPlan Excel, Macintosh 1985 . -, Excel ( MultiPlan). 1987 Microsoft Excel, - Windows ( Excel 2.0 for Windows, - , Macintosh). Win-dows , Excel 2.0 Windows - , , Excel. Microsoft Excel, 2.1(Excel Version 2.1). 1990 (2.1), Windows 3.0. 2JC - (. 1.3) , , , - . Excel (XLM), , . - , . -, XML VB, .

    , Microsoft Excel ( 2.20) OS/2 PresentationManager. 1989 , - ( 2.21). , IBM, - OS/2 .

    Pc. /.4. Excel 3 . ( - Microsoft)

    1990 Microsoft Excel 3 Windows -, , (. 1.4). - , , ,

    I Excel 39

  • , (Object Linking and Embedding OLE), , , , - . -, Excel 3 ( Q+E). Excel OS/2.

    4, 1992 , , , - (. 1.5). , , Excel 4 . - Microsoft IBM ; Excel 4 OS/2 , a Microsoft Excel, - .

    . 1.5. Excel 4, Excel 5 . ( Microsoft)

    Excel 5 1994 - . , , . Lotus 1-2-3 5 Windows Quattro Pro Windows , , , Excel 5 . -, , VBA.

    Excel 95 ( Excel 7) MicrosoftWindows 95. Microsoft , , Office, . . Excel 95 Excel 5. ,

    40 1. Excel 2002

  • . , Excel 95 - , Excel 5. , - Excel . , , VBA ., Excel 95 , - Excel 5 ( , ).

    1997 Microsoft Office 97, - Excel 97. , Excel 97 Excel 8. - , - VBA. - ( , ). Microsoft Excel 97 , -. , Excel 5 Excel 95, - Excel 97 , .

    26.

    Excel 2000 1999 ; - Office 2000. , Ex-cel 2000, , , Internet, .

    Excel 2002 2001 . , , , . -, , - . , - Excel. Excel .

    , , -

    , - . "" , . - , - . Excel . . , , , - Excel , .

    ? .

    . , - - , . -

    /. Excel 41

  • . , - .

    . , , , ( , ). : .

    . Lotus 1-2-3 Excel . , "". , " ".

    . - . , - , - . , - , Excel .

    . , . , , - .

    . " - ", - ( ).

    . - , , , . -, , .

    . - . , Excel. VBA, , Excel.

    . Internet. , -, " ", Web- -. , , - , . , Excel 95% , Internet.

    . , - .

    . ( - ).

    , Excel - , Windows. Windows , , - -. Excel ( , - , , , ). . Excel

    42 1. Excel 2002:

  • , . , Excel Microsoft.

    , Excel . , , Excel , - Windows . Microsoft - - ( ). Internet , - Web- , , Excel , Microsoft Office. , .

    Excel

    - . Excel 2 0 0 2 , - , VBA.

    Excel.

    . - . , . VBA - , .

    Visual Basic for Application (VBA). Excel. , Excel -. (, Lotus I-2-3 Lo-tusScript), .

    . Excel , , , , .. .

    . , . Excel 2002, - ( Excel 97) -, .

    . VBA .

    . , . , Excel - .

    . Excel - , , .

    I. Excel 43

  • . , . -, , Excel .

    . Excel, -, , .

    Microsoft Query. . , Web-.

    Data Access Objects (DAO) ActiveX Data Objects (ADO). , VBA.

    . - . , - , Excel .

    "" . XLA- , .

    . VBA, , . , Excel - Microsoft Word.

    Web-. Excel HTML.

    Excel Microsoft Excel Microsoft Office -

    , ( , - Office). , , . Microsoft . Office VBA.

    , Excel VBA, .

    . -

    , . , Excel - . , - Excel.

    Excel.

    44 1. Excel 2002:

  • Excel

    Excel 2002. -

    , Excel, (, Lotus 1-2-3, - Excel). , - Excel, , .

    ... Excel

    ( VBA), - , Excel, - . Excel:

    Excel;

    Excel;

    ;

    ;

    ListBox () - ( );

    ;

    .

    , - : Excel - , , , , . Excel. Excel - , VBA. Office 2002, Office.

  • VBA

    VBA Excel 5. ( Excel 95) VBA . VBA, , , , - VBA-. Excel 97, VBA . VBE (Visual Basic Editor Visual Basic). VBA VBE, . - .

    . , , Excel, ,

    VBA. - .

    Excel . , -

    Excel, , , - . x l s . Excel ( ). :

    ;

    ;

    XLM (, );

    ( , ).

    Excel 2002. , "" Excel 2002. , "".

    ( ), - . , - . , , - . . , .

    Excel 2002 , ^ ^ . - , .

    , . 1 *. , , .

    ?

    , ? - {256x65 536) , 16 777 216 ( ). .

    VGA , - 9 18 ( 162 ). 0,001%

    46 Z. Excel

  • . , - 104 000 VGA .

    ( ), , -, 194 . - 36 000 - .

    . - , , - . , , , Excel . , .

    . -

    , . Excel 256 65 536 . , , . , , - . , , - , Excel, Microsoft ( ) .

    , Excel 97, 16 384.

    - , . - . , ;! , - , , - . - , .

    , . , , - ("" "") . , , (, , , , , , ).

    Excel 2002, , - . -, Excel, - Excel 2002 "" .

    ( , -). ( ) - , .

    I. Excel 47

  • .

    , . , , - . , .

    XLM XLM ( MS Excel 4)

    , . , XLM , . , - , ,

    , XLM XLM. XLM "", Excel (4-0 ). , Excel 2002 - XLM, . - XLM . VBA.

    Excel 5/95 Excel 5 Excel 95 -

    . , Excel 97 - , (UserForm). Visual Basic .

    , Excel 5/95, .

    Excel5/95, . - . Excel 5.O.

    , - Excel 5/95- , Excel.

    Excel -

    . , , - , , .. Excel , , Windows, - , Excel - "" Windows.

    Excel Excel. , , "".

    48 2. Excel

  • Excel 97, .

    , . Excel . (

    , , ). Windows , , , , - . (, ).

    , , . , (-, , ^-). , .

    . ^ 1^. , , "". -, Excel , , - . , Excel 5 Excel 95, Excel 2002.

    , Excel 5 Excel95, Excel 5 Excel 95. , -.

    Excel , . , .

    23.

    Excel . -

    , , - Analysis ToolPack ( ) - .

    Excel -. . - , , (. 2.1). - 13 . , 11? .

    ( Excel 97). , ( MultiPage).

    IV.

    I. Excel 49

  • . 2.1. , , - , -

    Excel 2002 -

    ( ). , , . ^ 1^. -, .

    ( ) - . Excel .

    , , -. Excel , , - (. 2.2). , Excel - , , , - .

    . 2.2. , , , -

    50 2. Excel

  • Excel 2002 .

    . , , , . , . , - . . - , . . -.

    . , .. , - ^.

    . ,. , . . ( -).

    22.

    Excel, ,

    , , - . , .

    , Excel - . - , .

    ; .

    Windows, . ( ) OLE-.

    Excel . ,

    , . Excel - , , . Excel. , .

    /. Excel 51

  • ( , ,

    ..), , ., ^ , - , , - . , , ( ).

    Excel , , .

    Excel .

    Excel :

    ( / );

    ;

    ;

    ("" "").

    , - Excel, .

    , - . , , , . - , . -, ^. , , . , , , .

    , , . , , , , - .

    - , .

    -, . , , , .

    52 2. Excel

  • ( ). - , . , . - . 0, , ( ). - .

    , ( ). - ; - , - .

    .

    { - ), ^.

    (=). , Excel - , Lotus 1-2-3, (&), (+) (-). , , .

    ,

    Windows. , - . , , - . , . , , , , , , .

    , Excel 97, . Excel 97, - . , , .

    Excel : .

    "", .

    , (. 2.3). .

    , -, , ( ), .

    /. Excel 53

  • . 2.3. Excel

    , -

    . , , , . , if , . - .

    - : . ( ). , . , .

    Excel , . , ^ . - , - . , , - .

    ,

    . Excel , . , -, ( , ).

    54 2. Excel

  • 3, -.

    -

    , Excel . , , ,

    , . , , - , . , - .

    3.

    ,

    - . Excel - . , Analysis ToolPack, ( ).

    , . 2.4. , ( - -> ). , - .

    . 2.4. - -

    Excel 2002 , -. , , . , , - ASCII , - ,

    I. Excel 55

  • , Excel VBA - (. 10).

    ,

    , , , , (, , ), .

    Excel, , . - , , - .

    ,

    -, . , : - . , , .

    , , (. 2.5). , , , .

    . 2.5. , >

    ,

    Excel , . ^ ( - ). , - . , "" , - .

    , , , - , - .

    2. Excel

  • Excel 2002 . , - ^ (, 2.6). , - , , .

    . 2.6. Excel 2002 ,

    Excel . -, .

    Excel 2000, - . - , .

    , Excel . - , ( , ). - , .

    , ( ). - "" .

    , Excel ( , ). , (. 2.7). . , .

    -

    . Excel : XLM VBA. XLM . VBA. , Excel XLM, . VBA.

    /. Excel 57

  • . 2.7.

    VBA III.

    -

    { - Lotus 1-2-3). Excel.

    , , , .

    . , - . Excel 65 535 256 ( ).

    . - .

    58 2. Excel

  • , , Excel

    . , , , 1^-, , - .

    Excel, , . , -, , . - , . ^^. , , . . 2.8 , - ,

    Puc. 2.8. Excel , "",

    , , ^^ .

    ,

    ^ . Microsoft Query, , . .

    Excel 97, Web-, , Internet.

    , DAO (Data Access Objects ) ADO (ActiveX Data Objects ActiveX),

    I. Excel 59

  • , Excel, VBA , , , ADO , .

    Internet Excel , Internet, -

    , HTML, - Web-. , -, ( ).

    Excel HTML, -. , Web- Office, - Web- ( Web- Office).

    , Excel (

    ). - , Excel .

    -

    (, , ). Excel (, ), . , - .

    Excel ( )

    , . , Excel , .

    , ,

    , Lotus 1-2-3. Excel , . , .

    Analysis ToolPack Analysis ToolPack ( ) 19 -

    ( , ), . Excel - .

    60 2. Excel

  • , AnalysisTooLPack . - , . , , - , .

    Excel . -

    , . - . , -, VBA. , , - -, - .

    , VBA , 17.

    , Excel ,

    . -, ^ .

    Excel

    , "-" , , . Lotus 1-2-3 Windows QuattroPro Windows. ( , Frontline Systems.)

    , Excel -

    . , 1 1* .

    , Excel, , - Web- Microsoft. , ; , Internet. , - 21.

    I. Excel 61

  • , Excel, -

    . Excel , - . Excel , , . , Excel 97, Excel 2000 Excel 2002 , - , , Excel, , - .

    Excel , ( - 4).

    Lotus 1-2-3 DOS, , , - Excel.

    Excel. , - 26.

    Excel 2002, -

    . 3, .

    62 2. Excel

  • -, .

    "-". Excel .

    . -

    , { , ).

    Excel , ( , - ).

    , :

    , + () * ();

    ( -

    );

    ;

    (, ).

    1024- . . , , .

    Excel 2002, "".

  • Excel 2002 . -V , ,

    _| . , . - . . - . .

    , , , . -

    , , . , - . , , . - , , - .

    (, -). Excel - .

    Excel , , . , .

    . , - D12 D11, - D11, D12.

    , Excel , , . , , , . ( ).

    , . .

    .

    . - .

    . - ; . , Excel - , , , - VBA.

    Excel () -| . , * --"" .

    64 3.

  • , .

    ( ), , . .

    . . -, (: 1).

    . . , (: $$1).

    . . -, , , , (: $1).

    - . -, - , , , (: $1).

    . - , . -: , , , - .

    , , , -

    . , . 3.1. 4 :

    =$3*$4

    . 3.1.

    I. Excel 65

  • ( ) ( 3). , 8, , F8. ( 3, , ), - . , , .

    R1C1 , Excel 1. , -

    , , , , . , Excel RJC1.( R row, "", column, ""). 1 R1C1. 2 , R2C1 ..

    R1C1, ^ , R1C1. , . , it .

    . 3.1 , R1CI. , 1 ( R1C2).

    3 . 1 . , |

    R1C1

    s * l + l =RC[-1]+1

    =SA$1+1 =R1C1+1

    =SA1+1 =RC1+1

    =A$1+1 =R1C[-1]+1

    =(1:10) = (11[-1]:R[9]C[-1])

    ($$1:$$10) =CyMM(RlCl:R1OC1)

    R1C1 , -. , - , .

    . , Rf-5]C[-3] , , . , R[5]C[3] , . , . -, R[5]C , .

    , R1C1 , . , - R1C1, . (, -). RIC1 . -- , , , .

    66 3.

  • , VBA , , -, R1CI.

    , , -

    , . , , . , - :=2!1+1

    , , . ( ), . :=[.x l s ]1IA1 + 1

    , , , ( ) . :='[ 2002 ] 1 ' ! 1 + 1

    , . :

    =':\MSOffice\Excel\[ 2002 ]1'!1+1

    . - . . - ( - , ).

    Excel 2002 , . - ( Excel), - .

    Excel, -, ( ). , - , , . - , , B a d f i l e . x l s , , 1 , 1 1 := ': \Files\ [Badfile.xls]JlMCTl !1

    , . , - .

    . , - ^, , - ( ). : , .

    I. Excel 67

  • Excel

    . , ,, , . , Excel, , - ( '' ").

    ^ ^ -

    ( ). , ( , - ). , - , .

    , . ^^ . , . 3.2 , 4 : F4 , 5 : F5 .. , : 1, D3 : D6 2 ..

    . 3.2. Excel -

    VBA, - . ? - : , VBA, - , VBA- . , VBA- 4, Range ("4 " ) , , - . , , , Range (" I n t e r e s t R a t e " ) .

    , Excel

    , . , F10 :=1-2

    68 3.

  • Al , 2 , - =-. , . , -. ^^. - , , . , , .

    , "" . , , ^-*" . , , ,

    #?.

    Excel . , - , ., . . , . - , , - , ,

    VBA.Sub DeleteHiddenNames(}Dim n As NameDim Count As Integer

    For Each n In ActiveWorkbook.NamesIf Not n.Visible Then

    n.DeleteCount = Count + 1

    End IfNext nMsgBox " " & Count & " "

    End Sub

    Power Utility Pak ( Web- ) , "" .

    Excel ( ). -

    , -. . , . - . 3.2. :=2 ,

    440 ! .

    (), :

    =()

    I. Excel

  • " "

    Excel 97, " ", - . Excel . - ( ). , ( - " ")=

    , - .

    , . , , - VBA. , Microsoft . - . - .

    Excel .

    ! 2:5. , ! D .. "" 4, 5 ..

    , , , .

    , , . , , , 7, !.

    -

    , . , -

    . .; , - (, !!). , , . , , , , ., , . .

    , , , -, .

    Excel , (

    Excel ). , , -, , ( ).

    70 3.

  • , . (,), . , :=*

    (. 3.3). - , . -, , .

    . , . -, =, - .

    , .

    - . , , . , - , .

    . 3.4 (=11). . 1, , ( , -). - =, , , , . , 10 10 , , 3 4, - D10 , S1 (3 4- ):=

    . 3.3. Excel - -,

    . 3.4. -, -

    , , , . , D3 2, - :=1!321!32

    I. Excel 71

  • , . , , , . - , 1 , ( ). := ! 1 ! 1

    , , , -. , . , .

    Excel . . .

    , , .

    Excel , - , .. , . - , Excel.

    , , () . , - , .

    "", , .

    ,

    , , , . , VBA.

    , , - ^, ( ). , -, . , - .

    , , , . - .

    , , , , -

    . , , -, . " " , , . ,

    72 3.

  • , - .

    . 3.2 - , .

    3.2. Excel,

    # / ! (, -), ,

    # / ( ) , , . , . , # / ,

    #? , Excel . , , , , -

    # ! , - ( )

    # ! (, , - )

    # ! . ,

    # ! , , . , - , VBA- -

    , .

    , -. , ,' (Excel - ).

    , 1x5 1x5, 1x5. , ; -. , -. Al :5 - 1 : 5. :

    =1:5*1:5

    . - , , ({}), . !

    I. Excel 73

  • Excel

    , , . - , .

    . 3.5 Al :5. , , , -. , , - , .

    , - , , . 3.5, .

    1. 1 : 3 5 .

    2. :

    =(1:5)

    3. .

    . - , 1 : 5, -, Al :5 25 .

    , 1 : 5 , . , ( - ):=((Al:5))

    :

    {=((1:5))}

    ( ) , - , A l : 5. - - 25.

    . 3.6 , . -

    , , , 42- .

    Web- , .

    3.

    . 3.5. Bl , - , Al :5

  • . 3.6. , -

    .

    .

    .

    .

    , - .

    , .

    .

    .

    , .

    , Internet, .

    - . , , .

    Excel, , , ,

    , - . : , , ,

    I. Excel 75

  • , . , : ,, , - , .

    . 3.3 . , ( ). , , , .

    3.3.

    = (; 12) , , 12

    = (; D + , 1 12(,-12)

    = C O U N T I F (; - < 0 " ) ,

    = ( ; " < > " )

    = (; " > = i B ) ~ , 1 10(;">10")

    = (; " y e s " ) , yes () (

    )

    = (,-" * " ) ,

    = (,-" * s * " ) , s ( -)

    = ( ; " ? ? ? " )

    , , ( " "). , , , .

    ( -

    ), :

    =( (() ;1,-0) )

    , ,

    :

    =((();1;0))

    ( ; -

    ), :

    ( (; ) >0 ; 1; 0 } )

    . 3.4 , -, , 3.7.

    76 3.

  • . 3.7. , -

    3.4. ,

    =((2:10="")*(2:10="")*2:10)

    =(

  • , . , a Excel -. , 1 1999 , 01.06.1999( ). Excel 36312, - .

    , , -

    . , Excel, , , , . . Excel , , , , - : , . , - 1 1999 36312. ( ) - 36312,5. , .

    , - . , .

    , . , 0 1900 . -

    .. SA '&* . Excel ( -

    # # # # # # # # # ) . ? 1904 . ^ , 1904. , - .

    , , 24- . 24- Excel

    - ,-.-gv . , - ' ' : , -

    . , , 24- :[ h h ] : m m

    1900 , 1 1900 . , -

    Excel, , , , 1 1900 . , - . ,Excel , :4 1776 .

    , , , . -, , , - , , .

    78 3.

  • Web- Extended Date FunctionsWeb- \ { ). , -

    , 100- 9999- . . 3.8 , - 1900 .

    . 3.8. Extended Date Function v - 1900

    . .. , , , - . , , , . ? - (, , ), - . , "" . ? , .

    . , ( ) . , . , . , , - . -, .

    . 3.9.

    I. Excel 79

  • . 3.9 - , . 3.5. , . G, .

    3.5. , ! (. 3.9)

    1 = ( 1 )

    1 = (" ",- 1,-1)

    D1 = (" - ;1;1+1)

    1 = { { D 1 ) ; c i ; DI ) , -

    F1 = ( B l ; c i )

    G1 = (1;{1) - E l ) ( )

    HI = F l & G l

    , . : , - , ( ). , - . , Hi , ' 1. - :

    ={(1) ; { " " ; ( Al} ;1) )&1( (1) ; (1) )-(((" ";(1);("(1);1)+1>);{" ";(1);1);(" ";(1);{" ";(1);1)+1)))

    , , - , .

    , - , , , -, , -. ( , - ).

    , -, : Excel 1024 . -^*10 VBA -

    . , :NOMIDDLE(Al)

    , .

    , . . , - 65536 . ,

    80 3.

  • . VBA-. . 3.6 .

    I 3.6. VBA-

    ( )

    10,8 24,4

    6,2 8,9

    - 106J 8,6

    , , . .

    , , . VBA- - . VBA- -; , Excel.

    / Web- , / .

    Excel

    , , . - , .

    , , Excel .

    \. Excel 81

  • Excel

    Excel, -

    , -. , , Excel. .

    Excel Excel - ( -

    ). E x c e l . .

    , Excel - Windows - . ( , - ). ; -, . , . =>.

    x l s t a r t ( " Excel") , , . , - . , - 1 . - - .

    , ( ) , . ,

  • x l s t a r t Book.x l t . - .

    Excel , , . . 4. L

    4.1, Excel

    / a u t o m a t i o n Excel , x l s t a r t . - " " Excel

    / Excel "" . , Excel -

    / e m b e d d e d Excel ( )

    / Excel 4.0( )

    / Excel Windows, . (. . / r e g s e r v e r )

    / ,

    /

    /s Excel "" ; , - x l s t a r t

    / r e g s e r v e r Excel Windows, . , , Excel - , , ,

    / u n r e g s e r v e r Windows, -

    , , , Excel. , , X I f i l e s Excel, / , - . - , , . , :"C:\Program Files\Microsoft Office\Office\EXCEL.EXE" / C:\Xlfiles

    Excel. - . , , - , Excel. .

    I. Excel 13

  • Excel Excel , E x c e l . , .

    . . 4.2 ,

    Excel, ,

    .

    4.2. , Excel

    HTML-

    DLL (Dynamic Link Library). DLL - Windows

    . , Excel, . E x c e l .

    OLB (object type library)

    TXT ASCII-, (, , ). - ,

    XLA Excel. Excel. , ,

    XLS Excel. - Windows, E x c e i i o . x i b ( -, )

    XLC Excel 4 (, Excel 5)

    XLL Excel. ,

    Analysis TooPak ( )

    XLM Excel 4 (, Excel 5)

    XLS Excel. , Excel,

    XLT Excel *

    XLW , - . Excel 4 ( , , Excel 5, Excel )

    XLK

    Excel, Excel 2000, Windows { . h i p ) . Excel 2000, - , HTML, HTML- * , chin.

    84 4. Excel

  • Excel XLS, - , -.

    , . , , - , ? , , -, Excel ( XLS) , , , XLS.

    , XLS ( - XLS), ( - , ).

    , , Excel.

    Lotus 1-2-3 Lotus.

    WKS , Lotus 1-2-3 1 . DOS. Excel , .

    , Excel Microsoft Works, WKS.

    WKJ , Lotus 1-2-3 2_\ DOS. - * . a l l ( Allways) * . fml ( WYSIWYG (What You See Is What You Get, " , "). - Excel . * . wkl, , .

    WK3 Lotus 1-2-3 3.x DOS, Lotus 1-2-3 4..v DOS Lotus 1-2-3 l..v Windows. . * . fm3 ( WYSIWYG). Excel WK3. ( ) FM3.

    WK4 Lotus 1-2-3 4 .. Windows Lotus 1-2-3 - 5..V Windows ( Lotus, -, ). . Excel . - Excel WK4, -: Lotus I-2-3 4 Windows ( ) WK3, Excel .

    /. Excel 85

  • 123 Lotus 1-2-3 97 Lotus 1-2-3 Millennium Edition. - . Excel , Excel 123, . Lotus 1-2-3, WK3, Excel .

    Quattro Pro Quattro Pro .

    WQI , Quattro Pro DOS 1, 2, 3 4. ( Excel , .

    WQ2 Quattro Pro DOS 5. - Excel , .

    WBI Quattro Pro Windows 1 5 ( 2 4 -). Excel , .

    WB2 Quattro Pro Windows 6. Excel , .

    WB3 Quattro Pro Windows 7 8. Excel , .

    Web- Microsoft Quattro Pro. - WB3, Quattro Pro 97. - :

    http://oficeupdate.microsoft.com/downloadDetails/quattr97.htm.

    DBF , dBASfi -

    . Excel DBF dBASE 4 .

    , Excel . , - Microsoft Query, Excel . Microsoft Query Excel, * .

    .

    , .

    , , , - . Excel , , - . , Excel , * . tx1:.

    86 4. Excel

  • , , , . ( , , - .) . Excel , -, . . Excel , CSV.

    , , , . Excel , , . ,Excel , PRN.

    Excel , , - .

    , : , .

    , . - 1^ 1* .

    Excel .

    DIF (Data Interchange Format ) VisiCalc. . Excel -, .

    SYLK (SYmbolic LinK ) MultiPlan. SYLK . Excel , .

    , ExcelExcel . .

    XLS XLS, Excel 2002,

    , Excel 2000 Excel 97. Excel, Excel 97. , , Excel. , .

    Excel . - , XLS XLA.

    I. Excel 87

  • XLS

    , , , Ex-cel XLS. ; Excel, XLS, , , , , - . , VBA Excel, 13 .

    , . Visual BasicEditor ( Visual Basic) , , - Immediate, . , , VBA:

    Print ActiveWorkbook.FileFormat

    Immediate , - . , .

    Excel

    16 Excel 2

    29 Excel 3

    33 Excel 4

    39 Excel 5. 95

    -4143 Excel 97, 2000, 2002

    ,

    Excel. , , . " -'" XLW. ^ . Excel .

    , - , Excel. , - , , XLW. , ^ .

    ( XLT).

    , , -. , . , , - . - .

    , - ^ , - .

    88 4. Excel

  • * ' , Excel 2002 ^ ^ , -

    . , -, Web- Microsoft.

    , , , . - , .

    B o o k . x l t , . , S h e e t . x l t , , . , , Excel - -, .

    .

    Xlstan. Book. x l t S h e e t . xl t. , .

    Templates. , - .

    Templates Excel. &*** , VBA;

    '^ MsgBox Application.TemplatesPath

    Excel

    XLB. Excel 2002, - E x c e l l O . x l b . Excel; , - * . x l b . ( ) , .

    XLB, Excel, Excel 2002. - x l b .

    , .

    I s A d d i n T r u e (), ^.

    , Excel - . , , .

    Workbooks ( ).

    Excel . ; .

    I. Excel 89

  • Excel HTMLHTML World Wide Web. , , -

    HTML. HTML- , . - , .

    Excel 2000 , HTML - "" . , - HTML, HTML- Excel, - , , , Excel(, , , ), - . HTML , ,, Excel "" - , , .

    , HTML "" , Microsoft, , , " ". , , HTML .

    ? , Excel HTML

    "" . , . , , HTML. -, . . 4.1 , -

    . . ,

    HTML . - HTML-, Excel.

    HTML-. . , HTML- "" -, . HTML- HTML-. , , .

    90 4. Excel

    . -, Excel, , - . XLA, .

    Excel XLA, XLL (- Excel 2000) . Excel. , XLA.

    21.

  • HTML- ""Web-.

    , HTML

    HTML-, Excel.

    Excel HTML-. , HTML- - . , . , HTML- .

    < / h e a d > .

    . , - < s t y l e > < / s t y l e > , , -, < / h e a d > .

    "" , , - ( < t a b l e > . - , Excel .

    HTML-, , 4000 , Web-, . , - , Excel HTML-.

    HTML- , , -

    . , HTML-. , 1: A3 -

    , . . , Excel ( - !).

    HTML- ( 10 000). , - ( , ). -, , HTML- Excel.

    HTML-, , , . JavaScript (JavaScript , - Internet Explorer Netscape Navigator). HTML- - , HTML-. , , .

    HTML- ( , , ).

    GIF- ().

    /. Excel 91

  • CSS- ( , ).

    XML-. XML extensible Markup Language, .. - ( ). , .

    , 1 Excel HTML-. , MSO (MSO " Microsoft Office"). , Excel (, , -, , ..).

    , , , Excel HTML . , -, . , Excel - ^. HTML- , XLS-. : HTML , .

    ? HTML , -

    . 8 Excel HTML-, , . , HTML- , , - , , , "" . , - ( ), , - ( ).

    , HTML , , - . -. '. , . . -. , .

    HTML-, , -, . . 4.2 , Microsoft Internet Explorer.

    Script Editor?

    , , - Excel, Microsoft Script Editor( Microsoft). , - . HTML- JavaScript ( VBScript). 6 , , , .. . Excel VBA , Web.

    , , , HTML-, - , , .

    92 4. Excel

  • . HTML-. - , , . ActiveX. -, )-, Office 2000 .

    HTML, Excel 2000 2002. , ( ).

    . 4.2. Excel ,

    Excel Windows. ,

    , Excel -

    0 Windows 3.1 -

    OLE- . Windows 95 ( ), , , - .

    , . : S y s t e m . d a t ( )

    /. Excel

  • U s e r . d a t ( ). Windows.

    , P o l i c y . p o l , -

    , .

    (

    R e g e d i t . , Windows), , -

    . ,

    , .

    " , ...". . 4.3

    .

    . 4.3. .

    , . . . 4.3 , , ,

    .

    4.3. Windows

    HKEY_CLASSES_ROOT OLE, -

    HKEY_CURRENT4JSER u s e r . d a t , -

    ( , HKEYJJSERS)

    HKEY_LOCAL_MACHINE S y s t e m . d a t

    HKEYJJSERS

    HKEY_CURREWT_CONFIG

    HKEY_DYN J3ATA

    94 4, Excel

  • Excel, Excel 2002, HKEY_CURRBNT_USER\Software\Microsoft\OfficeM0.0\Excel ,

    , Excel .

    , ..

    Regedit. , , . , , , -

    . -, , . ( , .) - Windows .-, 1* . - ASCII- . , , -, ASCII-, ( ). - Regedit.

    , Excel, - .

    , Excel . , Excel . Excel ( , ), . , - Excel ( -), , Excel .

    . 4.4 , Excel 2002. , .

    4.4. , Excel

    Add-in Manager , ( ) 1 ^ . -

    , Excel. , , -

    Converters () () , Excel

    AutoSave ()

    Delete Commands , ( )

    I. Excel ft-

  • . 4.4

    Error Checking( )

    Init Commands( -)

    Init Menus ( - )

    Line Print ( )

    Options ()

    Recent Files ( )

    Resiliency( )

    Security ()

    Spell Checker ()

    Userlnfo ( )

    W K ? Settings{ WK?)

    ,

    , Lotus 1-2-3. Excel , - Lotus 1-2-3, /wgdu (Worksheet Global DefaultUpdate, " , ")

    , . , , .- Excel (, )

    { )

    ,

    ,

    -

    Lotus 1-2-3(, , FM1 FM3)

    , -

    Excel, ( )

    ( Excel ).

    ; , - " , ...".

    , Excel.

    Excel, ,

    Excel ( , HTML-

    ). , Excel,

    Windows. -

    , .

    I. II, -

    ! , .

    96 4. Excel

  • Excel

    I , ,

    Excel. 5 . 6 , , Excel-

  • - .

    . , . - , , , . - - Excel . .

    , , , . . , , , - . - , . , , . , , , (, , " "). . , , .

    , -

    , - (, , , Pascal BASIC) . , - , .

  • . - , , , , . , , , - . , .

    .

    , , , -.

    ( ).

    . , , -, .

    .

    ,

    , , - . , - . , - . , , .

    ( ) .

    , -, .

    , -, .

    , , - ( - ).

    , .

    , - ( Excel).

    , ( , , - , ).

    .

    , , , , .

    //. Excel

  • , , , - . ( ). ( ) , - . , .

    ? 15- .

    , . - .

    , - . . , -, .

    , . - , - , . , , .

    . - , . - ( ) , " " .

    , . - "", , -, . , . , , , , - . , - , , .

    , .

    .

    , .

    .

    , , .

    .

    ( ).

    .

    , .

    .

    .

    100 5.

  • 6.

    , ( - Excel). , Microsoft - , - . Excel - , , , , , -. , , . , - .

    , ( ,

    ) : .

    . , - , . 5.1. . , , ( ). - , , .

    ' 5.1.

    / -

    -

    -

    , - , . , , , . , . , , , .

    -

    , . - , , - , .

    . , .

    //. Excel 101

  • . , , , , ., . , , , . , , , . , , .

    , , , . , . , , , , . , , - . , , ( ), ., , , , - , .

    , , , , ,

    . , , , .

    - . Excel, Lotus 1-2-3 DOS. ( ?) - . . - , . , , - : . . 5.2.

    5.2. ?

    , - 12% 100%

    20% 9 1 %

    76% 82%

    76% 82%

    12% 82%

    12% 73%

    8% 73% 12% 64%

    102 5.

  • . 5.2

    68% 55% 72% 36% 28% 27% - 60% 18% , , 36% 18% 0% 9% 32% 0%

    , , , , , , , - . - .

    ,

    , - . - : -; ; .

    12% , , , , . , , , - . , , - .

    -, . . -, , , , . , - , 12 .

    , , , 90% - . -. -, , , - 8% , , . , - . , - , -

    U. Excel 103

  • . Lotus I-2-3. . .

    . Excel. , , , . , , , - , .. , , : .

    , , . ,

    , :

    ;

    ;

    , .

    , - . , , -, , .

    , , , , . , .

    , , , - . , - . . (.. ) , . (, , ). , .

    , , , , . - ( ) , .

    Excel.

    104 5.

  • . , Excel, -, .

    . - , . , .

    . - Excel, , , PageMaker.

    - , , , .

    . , Excel - . Internet ( -) , Excel .

    , , , . ,

    . , - . , - , .

    , -

    . , - . , . - . , , , .

    () :

    " ";

    " ";

    ;

    -"";

    -;

    ;

    ;

    "-";

    ;

    ;

    " ".

    .

    II. Excel 1Q5

  • " ", . -

    . , . . , . , . 12 , , .

    , , , , , . , - - . - . .

    " " , , ,

    , . , , . , , "" , , - .. - , , ( , ..) .

    , , " ", , . ( -). - : , , , , . , .

    , . , Excel, . - , : , . , , - , . , - , - .

    , , -

    " "., , - - . , - ( ).

    106 5.

  • . , , - " " - .

    , , , -. , , , , . , , .

    , - , Excel-. , , , , VBA- .. ( ) Excel (, , - ).

    -"* -"". -

    , - ; , . - . -, . , , - , , . - , . , , - , .

    , -"", , . , , : . , . , -"" , , .

    -

    . Excel , -. -. , - . , Excel, , , , , ( ) . , - , .

    . Excel 107

  • Power Utility ( ) - Excel. , - . , Excel. Web- - . , VBA-.

    - . , , , . - - , Excel. -, , , - . -, , .

    - , - . , Excel - : - Excel, , .

    , -. 6 16 , VBA Excel.

    , Excel , -

    . , -, . , VBA. , .

    10 , .

    (

    ), . - , (, ), . , - . - .

    . - VisiCalc ( ). - -, . , . -, , , , , ?

    108 5.

  • "-" , "-" ,

    . , , . -, "-" ( - ). , , , " , ...?". , - . , , .

    "-" , , . - - , . , - , - , ,

    , . ,, , . Excel 97, - 65 536 . - .

    , - ., Excel - , .

    , , , , , , Access.

    .

    Excel -, , . , , {executive information system EIS). .

    - . - Excel, , .

    /I. Excel 109

  • " " . " ",

    , . , , . , - , , .

    - " ". , . .

    . , -

    , , . - , - .

    110 5.

  • , - , , ,

    , Excel. , , . , " " . , , , - , . , , ( ) , .

    , .

    .

    , .

    -.

    , , - .

    .

    - ( ).

    -.

    , .

    .

    .

  • , - . - . , .

    ,

    . , - . - .

    , . (, - , ), - , , .

    , - .

    , . , .

    , , .

    , ( ) . , , , - . , , .

    , . , -, , - , .

    , , . , - , .

    , Excel ( Excel) . , - Microsoft , , . , - Microsoft Office .

    , . .

    , . - . ? , - . , , , , - , .

    112 6.

  • . , era . , - , , , , - . , ( ) .

    ,

    , - , .. , . . , -. , - , , - .

    , , , , . - Excel! , .

    "" Excel , , , , , , . - , , Excel . , , -, . , , .

    , .

    . , : , , .

    . , - . , .

    VBA. , : - VBA? .

    XLS. - , .

    Excel. Excel-: Excel 2002, , Excel 2000 Excel 97? Excel 95 Excel 5? Macintosh? , Excel , .

    . - . , "" ,

    IL Excel 113

  • . , - , , .

    . - , - Excel . Excel, , .

    . - , , .

    . , , , Excel , - . , , - , , . , , .

    , , , , .

    , . , . , , . - . - , -. , , , , - . , .

    . Excel . - 18 24 . , , , , . Excel 5, VBA, Excel" " . & , Excel, , , XLM, Excel 2, 3 4. Excel 5, -, .

    Excel 97 "". , Visual Basic, a , . Excel 2000 Excel 2002 , - , .

    Excel 2002 , , " -". Microsoft , - .NET, , Office . , VBA VSA (Visual Studio for Applications). VBA , , , .

    114 6.

  • VBA . , , , VBA , . VBA -, . VBA, , VBA. VBA .

    , -. , , , , , . . . - . , DDE OLE. , . .

    , , . - , , , ..

    . , - , , , - , .

    Excel: , , .. , , . , , , , , - Excel. , , - ( ) . - , - . \

    Excel , :

    ( );

    (, , L i s t B o x ( ) Command-B u t t o n ( )), ;

    ;

    ;

    .

    , .

    Excel Excel VBA, - "".

    U. Excel 115

  • - Excel, .

    , - .

    Excel 97 - , (UserForms).

    , , Excel 5/95, . , .

    . 6.1 , .

    , , . - ( ). - - Visual Basic (Visual Basic Editor VBE), - . , - ,

    . .]. -

    { -, , ..). - ActiveX.

    , Excel. - , .

    , , ( -, ). , , - , . - VB-.

    IV.

    ActiveX

    Excel ActiveX, , . . 6.2 - . -, , , .

    6.

  • , -, Web-.

    , - CommandButton. , .

    - - . , ActiveX - . , , - , .

    ActiveX . , - , Excel 5/95. ActiveX; . . - (. 6.1).

    6.1. Excel 1 ActiveX

    . 6.2. , , - , -

    ActiveX Excel

    Excel

    -

    ...

    97, 2000, 2002

    [, CommandButton1_Cl ick)

    , Properties

    5, 95, 97, 2000, 2002

    VBA-

    cl i c k () C h a n g e ()

    . Excel . ,

    II. Excel 117

  • { ) - . , , , , .

    Excel 97, Microsoft , - . 22, . . 6.3 - , Excel. Power Utility Pak. - .

    Excel. - VBA , ^ ^.

    22, VBA. VBA : - () .

    , ^ 1^ (. 6.4), "". , - (, ), !

    Excel 97, , Excel 5. Excel 97 ->>>* , , ,

    . , , - , , -: Excel 5 , .

    . 6.3. -

    . 6.4. - Excel

    , , - Excel, , . , VBA (

    118 6.

  • ). . 6.5 - , . , , - .

    . 6.5.

    23.

    Windows,

    Excel . - . , , , . Excel - , .. .

    , - , , , - , - , . - , , - . , - , , .

    Excel 97, .

    , - . , , (. 6.6). , - .

    U. Excel 119

  • . 6.6. - -

    22.

    , -

    , . - . Excel , ( ). , . , , , -. , , - , , .

    , , . , - . , . , , , , Excel. , , , , .

    , ,

    , , , . , . , .

    , . - , , , , - . . , . VBA , .

    Excel, "'".

    120 .

  • ,

    , - .

    ""

    ? , -, . , - , . - , , - Excel, .

    , . . , , . , VBA , , - , .

    ? Excel?

    , , , , Excel, , ( ) . . Excel , - . , , . , Excel, Microsoft , . , - , , . , . -, - . , , "" . - . Excel , . Excel. , , , . Excel - . , .

    ? , . , , , , , . ? . ? -. .

    . . .

    1. , ( ) , .

    2. , , .

    . Excel 121

  • . , - , . , . "'1 Excel (. "? Excel?"),

    , , . , . , , MOiyr , , ( ). , .

    , , - . , , , . , , - . ? - , , .

    -?

    . . -. - , . Excel, , , , , -. - ( ) , .

    - . - , . - - , - , ; , , .. - -, , . , , , - . , - - , ( ) .

    . , -

    . , -, . - , , , , .

    122 6.

  • , , - ( ) . Excel .

    , . ( .) , ^ - .

    , , . - ^ ^ .

    , , -. ( .) , ^ 1 ^ .

    Excel

    , Microsoft Excel - . - Excel . , . , Excel 2002 , . , ? - Excel . , . - , , , .

    . ( .) , ^ ^ . ( - ), { ! ^), ( ^^) (=>). , .

    Excel ( -), . . ^ . , . . - =? .

    , .

    Excel 2002 , . * - . -, . , - . , .

    //. Excel 123

  • , , ,

    , . , .

    - . , - Excel. , , . - , , .

    - , -. . , -, .

    . , , , Excel. - , , .

    , . , - , - .

    , , , - . , , M u l t i -P a g e ( ), .

    , }' .

    , , , .

    , -, .

    ,

    , . -, . , ( , , - ). , .

    , , . Excel, , , , - , , , ,

    124 6.

  • . : - .

    ? . , . , - , . VBA, ( , , ). VBA - , , , - .

    , - : . - Windows-. Excel- . , , , .

    23 ,

    .

    ? - . .

    ., , . . - . , VBA.

    / Microsoft Office (Microsoft Office Developers/Hi Edition) ,

    ' ****" .

    Excel 2000 Microsoft Authenticode, " ". ,, , - . , - . ( , ). - Web- Microsoft.

    , . ,

    II. Excel 125

  • ? -, , . "" , .

    Excel?

    , -, Excel. - Excel . , , : Microsoft Excel? , , . , - Excel ( ).

    , Microsoft - Excel - . - : , - - . , , , .

    ... Microsoft - Excel. Excel - Excel. , . - Web- Microsoft { h t t p : / /o f f i c e u p d a t e . m i c r o s o f t . con).

    , ,

    ? , -, ( ) . , - . . , . - , , - . . , - .

    . -, - . , ... .

    -

    , , . , - (, - ), , - , .

    126 6.

  • Excel, Excel .

    Excel 2002 , - - Excel 95, Excel 97 .

    , , , , , Excel 95, Excel. , - Excel 95, Excel 97, Excel 2000 Excel 2002, - (Excel 95), .

    , "" Excel. -, Microsoft . , - Excel 2000, Excel 2000 SR-1 Excel 2000 SR-2.

    25.

    , , ,

    Excel. , . - .

    25

    ,

    . , , , . , - . , , - . , , - , . - "", , .

    VBA, , -& . -

    -'4 ' | * " ". , , * .

    Windows :

    640x480 (.. VGA), 800x600 1024x768. , VGA, , VGA-, .

    II. Excel 127

  • VGA! , - , , .

    - . , , 800x600, VGA- . , , (.. ) . , , , , VGA-.

    , Windows , VGA . , VGA. He , - , -. , -, , , " -" VGA,

    ( 10), VBA. , , - - .

    , ,

    , .. - . , , nporpaMNfa Excel C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE. -, :. , , Win-dows WINDOWS. , - , -. , , VBA.

    .

    .

    128 6.

  • Visual Basic forApplications

    . VBA, --

    , - . VBA (- ) . , - , - .

  • I VisualBasic for Applications

    Excel, , . -

    , , Excel. - , -, Excel.

    BASIC

    BASIC . (- Beginner's All-purpose Symbolic Instruction Code -) , ., BASIC 1960- - - . BASIC - , .

    BASIC . , . , . - BASIC -, , .

    BASIC 1991 , - Microsoft Visual Basic Windows ( 6.0). - Windows. Visual Basic BASIC, , VBA-

    .

  • VBAExcel 5 , Visual Basic for Applica-

    tions (VBA). VBA Microsoft, Office 2002 - . , VBA Excel, Microsoft (, ). , , .

    VBA

    . , VBA -, (Excel, Word, Access, PowerPoint ..) - . -, .

    , Excel - , , , , , , , , . VBA -. VBA Excel . . , , !

    VBA XLM Excel 5 ( -

    ) XLM. Excel XLM, , Excel 97, - XLM. XLM ( , - , ), VBA.

    . 7.1 7.2 , XLM VBA. - . . , , VBA . - ( ), VBA .

    . 7.1. , XLM Excel,

    . Visual Basic for Applications 131

  • . 7.2. , VBA Excel, - VBA

    VBA Lotus Lotus I-2-3 ( DOS) -

    . , - . Lotus 1-2-3 DOS , - . , Lotus 1-2-3 DOS, , :/RWC-

    Lotus 1-2-3:

    /Range Name C r e a t e ( E n t e r )

    , , Lotus I-2-3 - . Lotus 1-2-3 , VBA (. ).

    VBA LotusScript Lotus 1-2-3 97, LotusScript ,

    VBA. LotusScript, , VBA .

    VBA "" ., , . , Lotus () , ( ) VBA Microsoft.

    VBA, , -

    , . , .

    VBA.

    VBA VBA.

    ( ) VBA, VBA.

    132 7. Visual Basic for Applications

  • VBA .

    , , , - . - T e s t : , :

    Sub T e s t ( )Sum = 1 + 1MsgBox ": " & Sum

    End Sub

    Sub, VBA .

    ( ). - VBA . AddTwo:F u n c t i o n AddTwo(arg l , arg2}AddTwo = argl + arg2

    End Function

    VBA , ( .- Excel).

    Excel , , , - , , . - , VBA.

    .

    . , Excel - A p p l i c a t i o n , , , Workbook( ). Workbook , ,W o r k s h e e t ( ) C h a r t (). W o r k s h e e t - , . Range (), P i v o t T a b l e ( ) .. Excel.

    .

    , W o r k s h e e t s - , CommandBars CommandBar. - .

    , , - -.

    , 1 . 1 :

    Application.Workbooks("KHMral.xls")

    K H M r a l . x l s Workbooks. Workbooks A p p l i c a t i o n . , 1 1 . x l s :A p p l i c a t i o n . W o r k b o o k s ( " 1 . x l s " ) . W o r k s h e e t s ( " J b t c r l " )

    , :

    A p p l i c a t i o n . W o r k b o o k s ! " K H M r a l . x l s " ) . W o r k s h e e t s ( " 1 " ) . R a n g e ( " A l " )

    Excel .

    1 , :

    W o r k s h e e t s { " ! " ) . R a n g e ( " A l " )

    III. Visual Basic for Applications 133

  • , 1 , :

    Range("1")

    .

    . ,

    , V a l u e () Name (), -

    , H a s T i t l e () ().

    VBA, .

    .

    , 1 1 :

    W o r k s h e e t s ( " ! " ) . R a n g e ( " A l " ) . V a l u e

    , . , - , VBA. Excel - .

    Excel workbook ( ). . Excel , workbook( Workbooks). - - Restaurant.

    Excel , , , , , VBA .. , . , worksheet ( ) Range (), pivottrable ( ), Shape () .. ; ( ) , , Kitchen, DiningArea Tables (). , Restau-rant. , Tables . . , Kitchen stove(), Vent i la t ionFan (), chef (-), sink () .. . , . Excel . , Range value Name, shape Width, Height .. . , stove , Temperature Num-berofBurners. V e n t i l a t i o n F a n (TurnedOn(), RPM ( ) ..).

    , Excel , . , ciearContents; Range. , - changeThermostat ( ) stove switchOn() Vent i la t ionFan.

    Excel . clearContents Range Value Range, , ChangeThermo-s t a t stove Temperature.

    VBA Excel. - - (" ").

    134 7. Visual Basic for Applications

  • VBA. ( -, .

    Al 1 Interest, VBA:Interest = Worksheets("1").Range("Al").Value

    .

    , . , Range C l e a r C o n t e n t s . .

    , - .

    , Al - :R a n g e ( " A l " ) . C l e a r C o n t e n t s

    VBA ( , ..).

    , VBA . - , .

    Visual Basic Excel 5 Excel 95 VBA . -

    Excel 97, VBA , VBA Visual Basic( V B E Visual Basic Editor).

    VBA ; . VBE.

    V B E , Excel. VBE, . VBE Excel; VBE Excel.

    VBE Excel VBE

    .

    .

    ^^ Visual Basic.

    Visual Basic, Visual Basic.

    Visual Basic Editor Microsoft ScriptEditor. . - HTML, VBScript JavaScript. - .

    ///. Visual Basic for Applications 135

  • . 7.3 Visual Basic. , VBE , . : , , , ..

    . 7.3. Microsoft Visual Basic

    VBEVBE . -

    Visual Basic.

    VBE, , , .

    , VBE. , . -, View^Immediate Window (^ ) - .

    VBE . ^ VBE, ,

    .

    Standard, -

    , , VBE ( ). VBE , Excel: , , - .. VBE - View^Toolbars^Customize ( 1^).

    Project Explorer Project Explorer -,

    Excel ( ). .

    136 7. Visual Basic for Applications

  • Project Explorer (" Project Explorer").

    Visual Basic Project Explorer , . , ( Hide ).

    ( Module) VBA.

    . , Project Explorer. , 1 , 1 Project Explorer. VB -, .

    Project Explorer, View Code ( ) - Project Explorer.

    " '.

    Immediate Immediate VBA,

    . . Immediate , . - Immediate, ( Hide ).

    Project Explorer Visual Basic Excel

    . , - . , - "" Project Explorer. "" . , - ToggleFolders ( ) ProjectExplorer. , , .

    . 7.4 Project Explorer - ( ).

    VBE , Project Explorer. , - , ProjectExplorer.

    Excel , Project Explorer . , Project Explorer . -

    . 7.4. Project Exp-lorer -

    . Visual Basic for Applications 137

  • , .

    M i c r o s o f t E x c e l O b j e c t s . ( ), , Act iveWorkbook. VBA, Modules , . Forms, U s e r F o r m ( -, ). -, C l a s s Modules .

    Excel 2002 { Tools^Refe-rences) : References. . , , ,

    VBA VBA, Project

    Explorer Insert^Module (^). * Insert6*Module .

    Excel VBA - .

    VBA VBA ,

    Project Explorer Fi le^Remove xxx ( -). , Remove xxx . . , ( ), (, 1).

    , R e f e r e n c e s ,

    . . , . , (, VBA - UserForm) .

    , Project Explorer File^Export File ( ). , - . , ( - ). UserForm, , UserForm.

    , Project Explorer - FileOlrnport File. ,

    138 7. Visual Basic for Applications

  • . , F\\e*>Export File.

    userFonn, . , - , Project Explorer .

    VBA, ,

    . . :

    ( Project Explorer);

    (, 1 1 Project);

    VBA;

    ( , );

    U s e r F o r m .

    VBE , -

    . . 7.5 .

    . 7.5.

    III. Visual Basic for Applications 139

  • Excel. ,, , .. , , - , . - , - . , .

    , . , .

    , . , , . , Project Explorer.

    VBE . Excel . Immediate, - . Immediate, VBA { ) :Workbooks ( " i n y a d d i n . x l a " ) . C l o s e

    , C l o s e Workbook, - . .

    VBA , .

    ( Sub). , - .

    . , ( VB Excel).

    . , .

    , VBA. , - , .

    VBA , -. VBA . VBA VBA; .

    , , . - . Excel . : sub ( ), . . , sub . - 9 10,

    , VBA, -. , - . , ,

    140 7. Visual Basic for Applications

  • , - . , ( 19) UserForm ( IV).

    VBA , -

    VBA . VBA . VBA. ( ) -: VBA.

    VBA .

    : .

    Excel, - VBA.

    , - .

    . -

    ... , .. . , (, If End I f ) . , , . "' ".

    VBA . , , , .

    VBA . , - , . , . , - VBA, .

    MsgBox " " & UCase(SHORTCUTMENUFILE) _& vbCrLf & vbCrLf & " _" & ThisWorkbook.Path & vbCrLf & vbCrLf & _", BudgetMan", v b C r i t i c a l , APPNAME

    , . , .

    Excel, VBE . -| , ,

    Undo () , . Redo (), , . , .

    : VBA, - :

    III. Visual Basic for Applications 141

  • Sub SayHelloOMsg = " " & Application.UserName & "?"Ans = MsgBox(Msgr vbYesNo)If Ans = vbMo Then

    MsgBox " ."Else

    MsgBox ", !"End If

    End Sub

    . 7.6 , VBA.

    . 7.6. VBA

    , VBE . , (=}, VBE . , - . , .

    S a y H e l l o , . .

    .

    Rurr^Run Sub/UserForm.

    Run Sub/UserForm .

    , . - (. 1.1), , . Excel. , Excel. ; , .

    . 7.7. , . 7.6

    Excel. - , VBE.

    VBA ( ). , VBE

    142 7. Visual Basic for Applications

  • . , VBE, a Excel - , . , - .

    ( ).

    ( ).

    (Msg Ans).

    ( &).

    VBA (MsgBox).

    VBA (vbYesNo vbNo).

    I f - T h e n - E l s e .

    ( ).

    , ?

    VBA -

    Excel. , S a y -

    H e l l o . , . - .

    , , . , - .

    1. ( ).

    2. ^^ .

    Excel .

    3. , .

    Excel VBA . Excel, VBA. , , , ( ).

    4. ^ .

    Excel .

    5. , 1- .

    6. ( ).

    Excel .

    , VBE ( ) Project Explorer. Modules, , Module 1, ( - Module"!, Module2). ,

    III. Visual Basic for Applications 143

  • , 7.1. Excel 2002, -, .

    7.1.

    Sub 1{)

    ' 1 1 19.08.2003

    With ActiveSheet.PageSetup.PrintTitleRows = "".PrintTitleColumns = ""

    End WithActiveSheet.PageSetup.PrintArea = ""With ActiveSheet.PageSetup

    .LeftHeader = ""

    .CenterHeader = ""

    .RightHeader = "n

    .LeftFooter = ""

    .CenterFooter = "

    .RightFooter = ""

    .LeftMargin = Application nchesToPoints(0.787401575)

    .RightMargin = Application.InchesToPoints(0.787401575)

    .TopMargin = Application.InchesToPoints(0.984251969)

    .EottomMargin = Application.InchesToPoints(0.984251969)

    . HeaderMargin = Application. InchesToPoints (0.5)

    .FooterMargin = Applicatior.InchesToPoints(0.5)

    .PrintHeadings = False

    .PrintGridlines = False

    .PrintComments = xlPrintNoCommentsPrintQuality = 1200.CenterHorizontally = False.CenterVertically = False.Orientation = xlLandscape.Draft = False.PaperSize xlPaperA4.FirstPageNumber - xlAutoma tic.Order = xlDownThenOver.BlackAndWhite = False.Zoom = 100.PrintErrors = xlPrintErrorsDisplayed

    End WithEnd Sub

    , , ( ). , , Excel , .

    , , , . , , , . , . :

    144 7. Visual Basic for Applications

  • Sub 1With ActiveSheet.PageSetup

    ,Orientation = xlLandscapeEnd With

    End Sub

    , , O r i e n t a t i o n . - ,