Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Microsoft Excel
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== VBA programming ==== {{Main|Visual Basic for Applications}} [[File:Functions in Excel.PNG|thumb|300px|Use of a user-defined function ''sq(x)'' in Microsoft Excel. The named variables ''x'' & ''y'' are identified in the ''Name Manager''. The function ''sq'' is introduced using the ''Visual Basic'' editor supplied with Excel.]] [[File:Subroutine in Excel.PNG|thumb|300px|Subroutine in Excel calculates the square of named column variable ''x'' read from the spreadsheet, and writes it into the named column variable ''y''.]] The Windows version of Excel supports programming through Microsoft's Visual Basic for Applications (VBA), which is a dialect of [[Visual Basic]]. Programming with VBA allows spreadsheet manipulation that is awkward or impossible with standard spreadsheet techniques. Programmers may write code directly using the Visual Basic Editor (VBE), which includes a window for writing code, debugging code, and code module organization environment. The user can implement numerical methods as well as automating tasks such as formatting or data organization in VBA<ref name="Press"> For example, by converting to Visual Basic the recipes in {{cite book|title=Numerical recipes: the art of scientific computing|author1=Press, William H. Press|author2=Teukolsky, Saul A.|author3=Vetterling, William T.|author4=Flannery, Brian P.|name-list-style=amp|year=2007|publisher=Cambridge University Press|isbn=978-0-521-88068-8|edition=3rd|url=https://books.google.com/books?id=1aAOdzK3FegC}} Code conversion to Basic from Fortran probably is easier than from C++, so the 2nd edition ({{ISBN|0521437210}}) may be easier to use, or the Basic code implementation of the first edition: {{cite book|title=Numerical recipes: routines and examples in BASIC|author=Sprott, Julien C.|year=1991|publisher=Cambridge University Press|isbn=978-0-521-40689-5|url=https://books.google.com/books?id=3-BfpBw7AqQC}} </ref> and guide the calculation using any desired intermediate results reported back to the spreadsheet. VBA was removed from Mac Excel 2008, as the developers did not believe that a timely release would allow porting the VBA engine natively to [[MacOS#Mac OS X|Mac OS X]]. VBA was restored in the next version, Mac Excel 2011,<ref>{{cite web|title=Excel|url=http://www.officeformachelp.com/excel/|url-status=dead|access-date=July 8, 2012|work=Office for Mac|publisher=OfficeforMacHelp.com|archive-date=June 19, 2012|archive-url=https://web.archive.org/web/20120619131821/http://www.officeformachelp.com/excel/}}</ref> although the build lacks support for [[ActiveX]] objects, impacting some high level developer tools.<ref>{{Cite web|title=Using Excel β PC or Mac? {{!}} Excel Lemon|url=https://www.excellemon.com/view/100-using-excel-pc-or-mac|archive-url=http://webarchive.loc.gov/all/20160921074527/https://www.excellemon.com/view/100-using-excel-pc-or-mac|url-status=dead|archive-date=September 21, 2016|website=excellemon.com|access-date=July 29, 2015}}</ref> A common and easy way to generate VBA code is by using the [[Macro (computer science)|Macro]] Recorder.<ref name="Walkenbach">However an increasing proportion of Excel functionality is not captured by the Macro Recorder leading to largely useless macros. Compatibility among multiple versions of Excel is also a downfall of this method. A macro recorder in Excel 2010 may not work in Excel 2003 or older. This is most common when changing colors and formatting of cells. {{cite book|author=Walkenbach, John|title=Excel 2007 VBA Programming for Dummies|publisher=Wiley|year=2007|isbn=978-0-470-04674-6|edition=Revised by Jan Karel Pieterse|page=79 ''ff''|chapter=Chapter 6: Using the Excel macro recorder|chapter-url=https://books.google.com/books?id=2IBbPiP3wOIC&pg=PA79}}</ref> The Macro Recorder records actions of the user and generates VBA code in the form of a macro. These actions can then be repeated automatically by running the macro. The macros can also be linked to different trigger types like keyboard shortcuts, a command button or a graphic. The actions in the macro can be executed from these trigger types or from the generic toolbar options. The VBA code of the macro can also be edited in the VBE. Certain features such as loop functions and screen prompt by their own properties, and some graphical display items, cannot be recorded but must be entered into the VBA module directly by the programmer. Advanced users can employ user prompts to create an interactive program, or react to events such as sheets being loaded or changed. Macro Recorded code may not be compatible with Excel versions. Some code that is used in Excel 2010 cannot be used in Excel 2003. Making a Macro that changes the cell colors and making changes to other aspects of cells may not be backward compatible. VBA code interacts with the spreadsheet through the Excel ''Object Model'',<ref name="Walkenbach2">{{cite book|title=cited work|author=Walkenbach, John|chapter-url=https://books.google.com/books?id=2IBbPiP3wOIC&pg=PA53|chapter=Chapter 4: Introducing the Excel object model|page=53 ''ff''|isbn=978-0-470-04674-6|date=February 2, 2007|publisher=John Wiley & Sons}}</ref> a vocabulary identifying spreadsheet objects, and a set of supplied functions or ''methods'' that enable reading and writing to the spreadsheet and interaction with its users (for example, through custom toolbars or ''command bars'' and ''message boxes''). User-created VBA [[subroutine]]s execute these actions and operate like macros generated using the macro recorder, but are more flexible and efficient.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Microsoft Excel
(section)
Add topic