... . . . . . . . . . 704
Excel2010PowerProgrammingwith VBA
Published by
Wiley Publishing, Inc.
111 River Street
Hoboken, NJ 07030-5774
www.wiley.com
Copyright â 2010 by Wiley Publishing, ...
Excel 2010
Power Programming
with VBA
Microsoft
đ
đ
John Walkenbach
BONUS CD-ROM!
Includes valuable examples, a searchable PDF
of the book, and more
PART
I
Some ... collection of useful Excel utili-
ties and many new worksheet functions. I developed this package exclusively with VBA.
I think you’ll find this product useful in your day-to-day work with Excel. You can...
... Introduction
Welcome to Excel 2013 PowerProgrammingwith VBA. If your job
involves developing Excel workbooks that others will use — or if you
simply want to get the most out of Excel — you've ... work with
Excel. You can also purchase the complete VBA source code for a
nominal fee. Studying the code is an excellent way to pick up some
useful programming techniques.
You can take Power ... with Other Applications
Starting an Application from Excel
Using the VBA Shell function
Displaying a folder window
Using the Windows ShellExecute API function
Activating an Application with Excel
Using...
... for Excel 4 workbook files (obsolete
beginning withExcel 5 because all files are workbooks).
XLK A backup file.
Excel versions prior to Excel 2000 used standard Windows Help files (*.hlp). Excel
2000 ... innovations to contend with.
Excel 5, which introduced VBA, represented a major paradigm shift for Excel developers.
Thousands of people up until that point earned their living developing Excel applications
that ... learning VBA while you’re developing applications with
it. In fact, I think it’s impossible to learn VBA without developing applications. If you’re like
me, you’ll find it much easier to learn VBA...
... Applications
With- End With constructs
The With- End With instruction construct enables you to perform multiple opera-
tions on a single object. To start understanding how the
With- End With construct
works, ... function in a VBA statement, just precede the function name
with
Application.WorksheetFunction
The following example demonstrates how to use an Excel worksheet function in a
VBA procedure. Excel s ... 7
4799-2 ch07.F 6/11/01 9:29 AM Page 167
179
Chapter 8 ✦ VBAProgramming Fundamentals
Entering VBA Code
VBA code, which resides in a VBA module, consists of instructions. The accepted practice...
... functions by using VBA.
With all the functions available in Excel and VBA, you may wonder why you would
ever need to create new functions. The answer: to simplify your work. With a bit
of planning, ... a VBA array
VBA includes a useful function called Array. The Array function returns a variant
that contains an array (that is, multiple values). If you’re familiar with array formu-
las in Excel, ... Applications
Working with Ranges
The examples in this section demonstrate how to manipulate worksheet ranges
with VBA.
The examples in this section are available on the companion CD-ROM.
Copying a range
Excel s...
... in English language ver-
sions of Excel. For applications that will be used with other language versions of
Excel, you can use the FindControl method, along with the Id property for the
command. ... compatible with Excel
5 and Excel 95).
✦ Control Toolbox toolbar. These are ActiveX controls. These controls are a subset of
those that are available for use on UserForms. These controls work only with ... available for use on UserForms. These controls work only with Excel
97 and later versions, and are not compatible withExcel 5 and Excel 95.
You can use the controls from either of these toolbars,...
... into
utilities.
Using VBA to Develop Utilities
When I received the beta version of Excel 5, I was blown away by VBA s potential.
VBA was light-years ahead of Excel s powerful XLM macro language, and it made
Excel ... Developing Excel Utilities with VBA
Figure 16-10: The author’s Power Utility Pak contains many useful Excel utilities.
Summary
In this chapter, I discussed why you might want to develop Excel utilities ... want to develop Excel utilities with VBA.
I also presented and explained the VBA code for my Text Tools utility. As you gain
more experience withprogramming Excel, you’ll probably have some...
... not execute.
Caution
Cross-
Reference
Programming Events in Older Versions of Excel
Versions of Excel prior to Office 97 also supported events, but the programming techniques
required to take ... worksheet.
Excel is capable of monitoring a wide variety of events, and
executing your VBA code when a particular event occurs.
Following are just a few examples of the types of events that
Excel ... of the con-
cept of Excel events, and I include many examples that you
can adapt to your own needs. As you’ll see, understanding
events can give your Excel applications a powerful edge.
19
19
CHAPTER
✦✦✦✦
In...
... instead of last).
Moving Up from Excel 5/95?
If you’ve customized menus using Excel 5 or Excel 95, you can pretty much forget every-
thing you ever learned. Beginning withExcel 97, menu customization ... and make it free- floating.
23
23
CHAPTER
✦✦✦✦
In This Chapter
An overview of
Excel s menu system
Types of menu
modifications you
can make
How to manipulate
menus with VBA
Various menu
programming
techniques ... There is no easy way to assign a VBA macro to a new menu item on the Tools
menu. This was a piece of cake withExcel 5/95. Later in this chapter, however, I pro-
vide VBA code that you can use to...
... Formats
Excel version Constant Value
Excel 2.1 xlExcel2 16
Excel 3.0 xlExcel3 29
Excel 4.0 xlExcel4Workbook 35
Excel 5 xlExcel5 39
Excel 95/97 xlExcel9795 43
Excel in HTML format xlHtml 44
Excel ... compatibility with
Excel 95, Excel 97, and Excel 2000, you should use Excel 95 for development, and
then test thoroughly using the other versions.
If your application must support Excel 95, you ... compatibility issue,
involving how your Excel 2002 applications will work with
earlier versions of Excel for Windows and Excel for Macintosh.
The fact that two versions of Excel may use the same file
format...
... A-1
Microsoft.com’s Excel- Related Newsgroups
Newsgroup Topic
microsoft.public. ProgrammingExcelwithVBA or XLM macros
excel. programming
microsoft.public. Converting 1-2-3 or Quattro Pro sheets into Excel ... Chapter 11 for details.
Excel 95 had a handy menu editor, but it’s missing in Excel 97
and later versions. What gives?
Beginning withExcel 97, the toolbars and menus in Excel are entirely different. ... preferred method. An add-in
opened with File ➪ Open cannot be closed without using VBA.
When I install my add-in using Excel s Add-Ins dialog box, it shows up
without a name or description. How...