<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-326775435754469619</id><updated>2011-11-09T12:52:51.331-08:00</updated><title type='text'>Excel</title><subtitle type='html'>A little bit about excel</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-3625337133767067288</id><published>2009-08-01T02:24:00.000-07:00</published><updated>2009-08-01T02:24:00.526-07:00</updated><title type='text'>Worksheets and Chart Sheets</title><content type='html'>&lt;p class="docText"&gt;Because the CodeNames of worksheets and chart sheets in your  project are treated by VBA as intrinsic object variables that reference those  sheets, the CodeNames given to worksheets and chart sheets should follow  variable naming conventions. Worksheet CodeNames are prefixed with wks to  identify them in code as references to Worksheet objects. Similarly, chart  sheets are prefixed with cht to identify them as references to Excel Chart  objects.&lt;/p&gt; &lt;p class="docText"&gt;For both types of sheets, the prefix should be followed by a  descriptive term indicating the sheet's purpose in the application. &lt;a class="docLink" href="#ch03fig04"&gt;Figure 3-4&lt;/a&gt;, for example, shows a  wksCommandBars worksheet that contains a table defining the command bars created  by the application. For sheets contained within an add-in or hidden in a  workbook and not designed to be seen by the user, the sheet tab name should be  identical to the CodeName. For sheets that are visible to the user, the sheet  tab name should be a friendly name, and one that you should be prepared for the  user to change. As discussed later, you should always rely on sheet CodeNames  rather than sheet tab names within your VBA code.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-3625337133767067288?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/3625337133767067288/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/08/worksheets-and-chart-sheets.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/3625337133767067288'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/3625337133767067288'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/08/worksheets-and-chart-sheets.html' title='Worksheets and Chart Sheets'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-5518062812534078711</id><published>2009-07-31T22:20:00.000-07:00</published><updated>2009-07-31T22:22:42.191-07:00</updated><title type='text'>Modules, Classes and Userforms</title><content type='html'>In our sample naming convention, the names of standard code modules should be  prefixed with an uppercase M, class modules with an uppercase C and userforms  with an upper case F. This has the advantage of neatly sorting these objects in  the VBE Project window if you don't care for the folder view.&lt;br /&gt;&lt;p class="docText"&gt;This convention also makes code that uses classes and userform  objects much clearer. In the following code sample, for example, this naming  convention makes it very clear that you are declaring an object variable of a  certain class type and then creating a new instance of that class:&lt;/p&gt;&lt;pre&gt;Dim clsMyClass As CMyClass&lt;br /&gt;Set clsMyClass = New CMyClass&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="docText"&gt;In each case, the name on the left is a class &lt;span class="docEmphBoldItalic"&gt;variable&lt;/span&gt;, and the object on the right is a &lt;span class="docEmphBoldItalic"&gt;class&lt;/span&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-5518062812534078711?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/5518062812534078711/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/07/modules-classes-and-userforms.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/5518062812534078711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/5518062812534078711'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/07/modules-classes-and-userforms.html' title='Modules, Classes and Userforms'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-6505942369267598349</id><published>2009-06-21T19:14:00.000-07:00</published><updated>2009-06-21T19:15:36.088-07:00</updated><title type='text'>Procedures</title><content type='html'>&lt;h4 class="docSection2Title"&gt;&lt;br /&gt;&lt;/h4&gt; &lt;p class="docText"&gt;Subroutines and functions are grouped under the more general  term &lt;span class="docEmphasis"&gt;procedure&lt;/span&gt;. Always give your procedures very  descriptive names. Once again, you are allowed up to 255 characters for your  procedure names, and procedure names appear in the Ctrl+Spacebar auto-complete  list, so don't sacrifice a name that makes the purpose of a procedure obvious  for one that's simply short.&lt;a name="ch03index26"&gt;&lt;/a&gt;&lt;a name="ch03index27"&gt;&lt;/a&gt;&lt;a name="ch03index28"&gt;&lt;/a&gt;&lt;a name="ch03index29"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;It is not a common practice to do so, but we find that giving  functions a prefix indicating the data type of their return value to be very  helpful in understanding code. When calling a function, always place open and  closed parenthesis after the function name to distinguish it from a variable or  subroutine name, even if the function takes no arguments. &lt;a class="docLink" href="#ch03list01"&gt;Listing 3-1&lt;/a&gt; shows a well-named Boolean function being  used as the test for an &lt;tt&gt;If...Then&lt;/tt&gt; statement.&lt;/p&gt;&lt;a name="ch03list01"&gt;&lt;/a&gt; &lt;h5 class="docExampleTitle"&gt;Listing 3-1. An Example of Naming Conventions for  Function Names&lt;/h5&gt;&lt;pre&gt;If bValidatePath("C:\Files") Then&lt;br /&gt;   ' The If...Then block is executed&lt;br /&gt;   ' if the specified path exists.&lt;br /&gt;End If&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="docText"&gt;Subroutines should be given a name that describes the task they  perform. For example, a subroutine named ShutdownApplication leaves little doubt  as to what it does. Functions should be given a name that describes the value  they return. A function named sGetUnusedFilename() can reasonably be expected to  return a filename.&lt;/p&gt; &lt;p class="docText"&gt;The naming convention applied to procedure arguments is exactly  the same as the naming convention for procedure-level variables. For example,  the bValidatePath function shown in &lt;a class="docLink" href="#ch03list01"&gt;Listing  3-1&lt;/a&gt; would be declared in the following manner:&lt;/p&gt;&lt;pre&gt;Function bValidatePath(ByVal sPath As String) As Boolean&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-6505942369267598349?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/6505942369267598349/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/06/procedures.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/6505942369267598349'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/6505942369267598349'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/06/procedures.html' title='Procedures'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-582325200479245151</id><published>2009-06-04T20:12:00.000-07:00</published><updated>2009-06-04T20:12:06.707-07:00</updated><title type='text'>Naming Convention Examples</title><content type='html'>&lt;h4 class="docSection2Title"&gt;&lt;br /&gt;&lt;/h4&gt; &lt;p class="docText"&gt;Naming convention descriptions in the abstract are difficult to  connect to real-world names, so we show some real-world examples of our naming  convention in this section. All of these examples are taken directly from  commercial-quality applications written by the authors.&lt;/p&gt;&lt;a name="ch03lev3sec6"&gt;&lt;/a&gt; &lt;h5 class="docSection3Title"&gt;Variables&lt;/h5&gt; &lt;ul&gt;&lt;li&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;&lt;tt&gt;gsErrMsg&lt;/tt&gt;&lt;/span&gt; A public  variable with the data type String used to store an error message&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;&lt;tt&gt;mauSettings()&lt;/tt&gt;&lt;/span&gt; A  module-level array of user-defined type that holds a list of settings&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;&lt;tt&gt;cbrMenu&lt;/tt&gt;&lt;/span&gt; A local  variable with the data type CommandBar that holds a reference to a menu  bar&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a name="ch03lev3sec7"&gt;&lt;/a&gt; &lt;h5 class="docSection3Title"&gt;Constants&lt;/h5&gt; &lt;ul&gt;&lt;li&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;&lt;tt&gt;gbDEBUG_MODE&lt;/tt&gt;&lt;/span&gt; A public  constant of type Boolean that indicates whether the project is in debug mode&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;&lt;tt&gt;msCAPTION_FILE_OPEN&lt;/tt&gt;&lt;/span&gt; A  module-level constant of data type String that holds the caption for a  user-defined file open dialog (&lt;tt&gt;Application.GetOpenFilename&lt;/tt&gt; in this  instance)&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;&lt;tt&gt;lOFFSET_START&lt;/tt&gt;&lt;/span&gt; A local  constant of data type Long holding the point at which we begin offsetting from  some Range object&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a name="ch03lev3sec8"&gt;&lt;/a&gt; &lt;h5 class="docSection3Title"&gt;User-Defined Types&lt;/h5&gt; &lt;p class="docText"&gt;The following is a public user-defined type that is used to  store the dimensions and location of an object. It consists of four variables of  data type Double that store the top, left, width and height of the object and a  variable of data type Boolean used to indicate whether the settings have been  saved.&lt;a name="ch03index21"&gt;&lt;/a&gt;&lt;/p&gt;&lt;pre&gt;Public Type DIMENSION_SETTINGS&lt;br /&gt;   bSettingsSaved As Boolean&lt;br /&gt;   dValTop As Double&lt;br /&gt;   dValLeft As Double&lt;br /&gt;   dValHeight As Double&lt;br /&gt;   dValWidth As Double&lt;br /&gt;End Type&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="docText"&gt;The variables within a user-defined type definition are called  &lt;span class="docEmphBoldItalic"&gt;member variables&lt;/span&gt;. These can be declared in  any order. However, our naming convention suggests you sort them alphabetically  by data type unless there is a strong reason to group them in some other  fashion.&lt;a name="ch03index22"&gt;&lt;/a&gt;&lt;a name="ch03index23"&gt;&lt;/a&gt;&lt;/p&gt;&lt;a name="ch03lev3sec9"&gt;&lt;/a&gt; &lt;h5 class="docSection3Title"&gt;Enumerations&lt;/h5&gt; &lt;p class="docText"&gt;The following is a module-level enumeration used to describe  various types of days. The sch prefix in the name of the enumeration stands for  the application name. This enumeration happens to come from an application  called Scheduler. DayType in the enumeration name indicates the purpose of the  enumeration and each of the individual enumeration members has a unique suffix  that describes what it means.&lt;a name="ch03index24"&gt;&lt;/a&gt;&lt;/p&gt;&lt;pre&gt;Private Enum schDayType&lt;br /&gt;   schDayTypeUnscheduled&lt;br /&gt;   schDayTypeProduction&lt;br /&gt;   schDayTypeDownTime&lt;br /&gt;   schDayTypeHoliday&lt;br /&gt;End Enum&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="docText"&gt;If you don't indicate what values you want to give your  enumeration members, VBA automatically assigns a value of zero to the first  member in the list and increments that value by one for each additional member.  You can easily override this behavior and assign a different starting point from  which VBA will begin incrementing. For example, to make the enumeration above  begin with one instead of zero, you would do the following:&lt;/p&gt;&lt;pre&gt;Private Enum schDayType&lt;br /&gt;   schDayTypeUnscheduled = 1&lt;br /&gt;   schDayTypeProduction&lt;br /&gt;   schDayTypeDownTime&lt;br /&gt;   schDayTypeHoliday&lt;br /&gt;End Enum&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="docText"&gt;VBA will continue to increment by one for each member after the  last member for which you've specified a value. You can override automatic  assignment of values to all of your enumeration members by simply specifying  values for all of them.&lt;/p&gt; &lt;p class="docText"&gt;&lt;a class="docLink" href="#ch03fig03"&gt;Figure 3-3&lt;/a&gt; shows one of  the primary advantages of using enumerations. VBA provides you with an  auto-complete list of potential values for any variable declared as a specific  enumeration.&lt;/p&gt;&lt;h4 class="docSection2Title"&gt;Procedures&lt;/h4&gt; &lt;p class="docText"&gt;Subroutines and functions are grouped under the more general  term &lt;span class="docEmphasis"&gt;procedure&lt;/span&gt;. Always give your procedures very  descriptive names. Once again, you are allowed up to 255 characters for your  procedure names, and procedure names appear in the Ctrl+Spacebar auto-complete  list, so don't sacrifice a name that makes the purpose of a procedure obvious  for one that's simply short.&lt;a name="ch03index26"&gt;&lt;/a&gt;&lt;a name="ch03index27"&gt;&lt;/a&gt;&lt;a name="ch03index28"&gt;&lt;/a&gt;&lt;a name="ch03index29"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;It is not a common practice to do so, but we find that giving  functions a prefix indicating the data type of their return value to be very  helpful in understanding code. When calling a function, always place open and  closed parenthesis after the function name to distinguish it from a variable or  subroutine name, even if the function takes no arguments. &lt;a class="docLink" href="#ch03list01"&gt;Listing 3-1&lt;/a&gt; shows a well-named Boolean function being  used as the test for an &lt;tt&gt;If...Then&lt;/tt&gt; statement.&lt;/p&gt;&lt;a name="ch03list01"&gt;&lt;/a&gt; &lt;h5 class="docExampleTitle"&gt;Listing 3-1. An Example of Naming Conventions for  Function Names&lt;/h5&gt;&lt;pre&gt;If bValidatePath("C:\Files") Then&lt;br /&gt;   ' The If...Then block is executed&lt;br /&gt;   ' if the specified path exists.&lt;br /&gt;End If&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="docText"&gt;Subroutines should be given a name that describes the task they  perform. For example, a subroutine named ShutdownApplication leaves little doubt  as to what it does. Functions should be given a name that describes the value  they return. A function named sGetUnusedFilename() can reasonably be expected to  return a filename.&lt;/p&gt; &lt;p class="docText"&gt;The naming convention applied to procedure arguments is exactly  the same as the naming convention for procedure-level variables. For example,  the bValidatePath function shown in &lt;a class="docLink" href="#ch03list01"&gt;Listing  3-1&lt;/a&gt; would be declared in the following manner:&lt;/p&gt;&lt;pre&gt;Function bValidatePath(ByVal sPath As String) As Boolean&lt;br /&gt;&lt;/pre&gt;&lt;p class="docText"&gt;&lt;a name="ch03index25"&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-582325200479245151?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/582325200479245151/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/06/naming-convention-examples.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/582325200479245151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/582325200479245151'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/06/naming-convention-examples.html' title='Naming Convention Examples'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-5284716540069742943</id><published>2009-06-03T20:00:00.000-07:00</published><updated>2009-06-03T20:00:05.006-07:00</updated><title type='text'>A Sample Naming Convention</title><content type='html'>&lt;h4 class="docSection2Title"&gt;&lt;br /&gt;&lt;/h4&gt; &lt;p class="docText"&gt;A good naming convention applies not just to variables, but to  all the elements of your application. The sample naming convention we present  here covers all the elements in a typical Excel application. We begin with a  discussion of variables, constants and related elements, because these are the  most common elements in any application. &lt;a class="docLink" href="#ch03table01"&gt;Table 3-1&lt;/a&gt; shows the general format of the naming  convention. The specific elements of the naming convention and their purposes  are described afterward.&lt;a name="ch03index07"&gt;&lt;/a&gt;&lt;a name="ch03index08"&gt;&lt;/a&gt;&lt;/p&gt;&lt;a name="ch03table01"&gt;&lt;/a&gt; &lt;p&gt; &lt;table class="allBorders" border="1" cellpadding="5" cellspacing="0" rules="groups"&gt; &lt;caption&gt; &lt;h5 class="docTableTitle"&gt;Table 3-1. A Naming Convention for Variables, Constants,  User-Defined Types and Enumerations&lt;/h5&gt;&lt;/caption&gt; &lt;colgroup&gt; &lt;col width="170"&gt; &lt;col width="379"&gt;&lt;/colgroup&gt; &lt;thead&gt; &lt;tr&gt; &lt;th class="bottomBorder thead" scope="col" align="left" valign="top"&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;Element&lt;/span&gt;&lt;/p&gt;&lt;/th&gt; &lt;th class="bottomBorder thead" scope="col" align="left" valign="top"&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;Naming  Convention&lt;/span&gt;&lt;/p&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Variables&lt;a name="ch03index09"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;&lt;tt&gt;&lt;scope&gt;&lt;array&gt;&lt;data&gt;DescriptiveName&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Constants&lt;a name="ch03index10"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;&lt;tt&gt;&lt;scope&gt;&lt;data&gt;DESCRIPTIVE_NAME&lt;/tt&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;User-defined types&lt;a name="ch03index11"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt;&lt;pre&gt;Type DESCRIPTIVE_NAME&lt;br /&gt;   &lt;data&gt;DescriptiveName&lt;br /&gt;End Type&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Enumerations&lt;a name="ch03index12"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt;&lt;pre&gt;Enum &lt;project&gt;GeneralDescr&lt;br /&gt;   &lt;project&gt;GeneralDescrSpecificName1&lt;br /&gt;   &lt;project&gt;GeneralDescrSpecificName2&lt;br /&gt;End Enum&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;br /&gt;&lt;a name="ch03lev3sec1"&gt;&lt;/a&gt; &lt;h5 class="docSection3Title"&gt;The Scope Specifier (&lt;tt&gt;&lt;scope&gt;&lt;/tt&gt;)&lt;/h5&gt; &lt;blockquote&gt; &lt;p&gt; &lt;/p&gt;&lt;p class="docText"&gt;&lt;tt&gt;g&lt;/tt&gt; Public&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;&lt;p class="docText"&gt;&lt;tt&gt;m&lt;/tt&gt; Module level&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;&lt;p class="docText"&gt;&lt;span class="docEmphRoman"&gt;(nothing)&lt;/span&gt; Procedure level&lt;/p&gt; &lt;/blockquote&gt;&lt;a name="ch03lev3sec2"&gt;&lt;/a&gt; &lt;h5 class="docSection3Title"&gt;The Array Specifier (&lt;tt&gt;&lt;array&gt;&lt;/tt&gt;)&lt;/h5&gt; &lt;blockquote&gt; &lt;p&gt; &lt;/p&gt;&lt;p class="docText"&gt;&lt;tt&gt;a&lt;/tt&gt; Array&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;&lt;p class="docText"&gt;&lt;span class="docEmphRoman"&gt;(nothing)&lt;/span&gt; Not an array&lt;/p&gt; &lt;/blockquote&gt;&lt;a name="ch03lev3sec3"&gt;&lt;/a&gt; &lt;h5 class="docSection3Title"&gt;The Data Type Specifier (&lt;tt&gt;&lt;data&gt;&lt;/tt&gt;)&lt;/h5&gt; &lt;p class="docText"&gt;There are so many data types that it's difficult to provide a  comprehensive list of prefixes to represent them. The built-in types are easy.  The most frequently used built-in types get the shortest prefixes. Problems  arise when naming object variables that refer to objects from various  applications. Some programmers use the prefix obj for all object names. This is  not acceptable. However, devising consistent, unique and reasonably short  prefixes for every object type you will ever use is also probably too much to  ask. Try to find reasonably meaningful one- to three-letter prefixes for the  object variables you use most frequently and reserve the obj prefix for objects  that appear infrequently in your code.&lt;a name="ch03index13"&gt;&lt;/a&gt;&lt;a name="ch03index14"&gt;&lt;/a&gt;&lt;a name="ch03index15"&gt;&lt;/a&gt;&lt;a name="ch03index16"&gt;&lt;/a&gt;&lt;a name="ch03index17"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;Make your code clear, and above all, be consistent. Keep data  type prefixes to three characters or fewer. Longer prefixes, in combination with  scope and array specifiers, make for unwieldy variable names. &lt;a class="docLink" href="#ch03table02"&gt;Table 3-2&lt;/a&gt; shows some suggested prefixes for the most  commonly used data types.&lt;/p&gt;&lt;a name="ch03table02"&gt;&lt;/a&gt; &lt;p&gt; &lt;table class="allBorders" border="1" cellpadding="5" cellspacing="0" rules="groups"&gt; &lt;caption&gt; &lt;h5 class="docTableTitle"&gt;Table 3-2. Suggested Naming Convention  Prefixes&lt;/h5&gt;&lt;/caption&gt; &lt;colgroup&gt; &lt;col width="70"&gt; &lt;col width="98"&gt; &lt;col width="59"&gt; &lt;col width="125"&gt; &lt;col width="59"&gt; &lt;col width="136"&gt;&lt;/colgroup&gt; &lt;thead&gt; &lt;tr&gt; &lt;th class="bottomBorder thead" scope="col" align="left" valign="top"&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;Prefix&lt;/span&gt;&lt;/p&gt;&lt;/th&gt; &lt;th class="bottomBorder thead" scope="col" align="left" valign="top"&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;Data Type&lt;/span&gt;&lt;/p&gt;&lt;/th&gt; &lt;th class="bottomBorder thead" scope="col" align="left" valign="top"&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;Prefix&lt;/span&gt;&lt;/p&gt;&lt;/th&gt; &lt;th class="bottomBorder thead" scope="col" align="left" valign="top"&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;Data Type&lt;/span&gt;&lt;/p&gt;&lt;/th&gt; &lt;th class="bottomBorder thead" scope="col" align="left" valign="top"&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;Prefix&lt;/span&gt;&lt;/p&gt;&lt;/th&gt; &lt;th class="bottomBorder thead" scope="col" align="left" valign="top"&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;Data  Type&lt;/span&gt;&lt;/p&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;b&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Boolean&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;cm&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;ADODB.Command&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;cbo&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;MSForms.ComboBox&lt;sup class="docFootnote"&gt;&lt;a class="docLink" href="#ch03tn01"&gt;[*]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;byt&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Byte&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;cn&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;ADODB.Connection&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;chk&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;MSForms.CheckBox&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;cur&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Currency&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;rs&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;ADODB.Recordset&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;cmd&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;MSForms.CommandButton&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;dte&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Date&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;ddn&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;MSForms.ComboBox&lt;sup class="docFootnote"&gt;&lt;a class="docLink" href="#ch03tn02"&gt;[**]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;dec&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Decimal&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;cht&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Excel.Chart&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;fra&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;MSForms.Frame&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;d&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Double&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;rng&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Excel.Range&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;lbl&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;MSForms.Label&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;i&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Integer&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;wkb&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Excel.Workbook&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;lst&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;MSForms.ListBox&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;l&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Long&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;wks&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Excel.Worksheet&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;mpg&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;MSForms.MultiPage&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;obj&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Object&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;opt&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;MSForms.OptionButton&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;sng&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Single&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;cbr&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Office.CommandBar&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;spn&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;MSForms.SpinButton&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;s&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;String&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;ctl&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Office.CommandBarControl&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="bottom"&gt; &lt;p class="docText"&gt;txt&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="bottom"&gt; &lt;p class="docText"&gt;MSForms.TextBox&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;u&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;User-defined type&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;v&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Variant&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;cls&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;User-defined&lt;/p&gt; &lt;p class="docText"&gt;class variable&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="bottom"&gt; &lt;p class="docText"&gt;ref&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="bottom"&gt; &lt;p class="docText"&gt;RefEdit Control&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;frm&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;Userform variable&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;col&lt;/p&gt;&lt;/td&gt; &lt;td class="docTableCell" align="left" valign="top"&gt; &lt;p class="docText"&gt;VBA.Collection&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;br /&gt;&lt;blockquote&gt; &lt;p class="docFootnote"&gt;&lt;sup&gt;&lt;a name="ch03tn01"&gt;[*]&lt;/a&gt;&lt;/sup&gt; Used for ComboBox  controls with a DropDownCombo Style setting.&lt;/p&gt;&lt;/blockquote&gt; &lt;blockquote&gt; &lt;p class="docFootnote"&gt;&lt;sup&gt;&lt;a name="ch03tn02"&gt;[**]&lt;/a&gt;&lt;/sup&gt; Used for ComboBox  controls with a DropDownList Style setting.&lt;/p&gt;&lt;/blockquote&gt;&lt;a name="ch03lev3sec4"&gt;&lt;/a&gt; &lt;h5 class="docSection3Title"&gt;Using Descriptive Names&lt;/h5&gt; &lt;p class="docText"&gt;VBA gives you up to 255 characters for each of your variable  names. Use a few of them. Don't try to save yourself a little effort by making  your variable names very short. Doing so will make your code difficult to  understand in the long run, both for you and for anyone else who has to work on  it.&lt;/p&gt; &lt;p class="docText"&gt;The Visual Basic IDE provides an auto-complete feature for  identifiers (all the names used in your application). You typically need to type  only the first few characters to get the name you want. Enter the first few  characters of the name and press Ctrl+Spacebar to activate an auto-complete list  of all names that begin with those characters. As you type additional  characters, the list will continue to narrow down. In &lt;a class="docLink" href="#ch03fig01"&gt;Figure 3-1&lt;/a&gt;, the Ctrl+Spacebar shortcut has been used to  display a list of message string constants available to add to a message box.&lt;/p&gt;&lt;h5 class="docSection3Title"&gt;A Few Words About Enumerations&lt;/h5&gt; &lt;p class="docText"&gt;Enumerations are a special type of constant available in Excel  2000 and higher. They enable you to take a list of related values and package  them up with similar, logical friendly names. VBA and the Excel object model  make extensive use of enumerations. You can see these in the auto-complete list  that VBA provides for the values of many properties. For example if you  type:&lt;/p&gt;&lt;pre&gt;Sheet1.PageSetup.PaperSize =&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="docText"&gt;into a VBA module, you'll be prompted with a long list of  &lt;tt&gt;XlPaperSize&lt;/tt&gt; enumeration members that represent the paper sizes  available to print on. &lt;a class="docLink" href="#ch03fig02"&gt;Figure 3-2&lt;/a&gt; shows  this in action.&lt;/p&gt;&lt;p class="docText"&gt;These names actually represent numeric constants whose values  you can examine if you look them up in the Object Browser, discussed in &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch16.html#ch16"&gt;Chapter 16&lt;/a&gt; VBA  Debugging&lt;/span&gt;. Notice the structure of these enumeration names. First, they  all begin with a prefix identifying the application they are associated with, in  this case xl, which obviously stands for Excel. Second, the first part of their  name is a descriptive term that ties them together visually as belonging to the  same enumerated type, in this case Paper. The last part of each enumeration name  is a unique string describing the specific value. For example,  &lt;tt&gt;xlPaper11x17&lt;/tt&gt; represents 11x17 paper and &lt;tt&gt;xlPaperA4&lt;/tt&gt; represents  A4 paper. This system for naming enumerated constants is very common and is the  one we use in this book.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-5284716540069742943?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/5284716540069742943/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/06/sample-naming-convention.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/5284716540069742943'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/5284716540069742943'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/06/sample-naming-convention.html' title='A Sample Naming Convention'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-4816189950870782278</id><published>2009-06-01T19:54:00.000-07:00</published><updated>2009-06-01T19:59:54.233-07:00</updated><title type='text'>Naming Conventions</title><content type='html'>&lt;h4 class="docSection2Title"&gt;What Is a Naming Convention and Why Is It  Important&lt;/h4&gt; &lt;p class="docText"&gt;The term &lt;span class="docEmphBoldItalic"&gt;naming convention&lt;/span&gt;  refers to the system you use to name the various parts of your application.  Whenever you declare a variable or create a userform, you give it a name. You  implicitly name objects even when you do not give them a name directly by  accepting the default name provided when you create a userform, for example. One  of the hallmarks of good programming practice is the consistent use of a clearly  defined naming convention for all parts of your VBA application.&lt;a name="ch03index01"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;Let's look at an example that may help demonstrate why naming  conventions matter. In the following line of code, what do you know about  &lt;tt&gt;x&lt;/tt&gt;?&lt;a name="ch03index02"&gt;&lt;/a&gt;&lt;/p&gt;&lt;pre&gt;x = wksDataSheet.Range("A1").Value&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="docText"&gt;From its usage you can reasonably assume it is a variable. But  what data type is it designed to hold? Is its scope public, module level, or  private? What is its purpose in the program? As it stands, you cannot answer any  of these questions without spending some time searching through the rest of the  code. A good naming convention conveys the answers to these questions with a  simple visual inspection of the variable name. Here's a revised example. (We  cover the specifics in detail in the next section.)&lt;/p&gt;&lt;pre&gt;glListCount = wksDataSheet.Range("A1").Value&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="docText"&gt;Now you know the scope of the variable (&lt;tt&gt;g&lt;/tt&gt; stands for  global or public scope), what data type it was designed to hold (&lt;tt&gt;l&lt;/tt&gt;  stands for the Long data type) and have a rough idea of the purpose of the  variable (it holds the number of items in a list).&lt;a name="ch03index03"&gt;&lt;/a&gt;&lt;a name="ch03index04"&gt;&lt;/a&gt;&lt;a name="ch03index05"&gt;&lt;/a&gt;&lt;a name="ch03index06"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;A naming convention helps you to immediately recognize the type  and purpose of the building blocks used in an application. This enables you to  concentrate on what the code is doing rather than having to figure out how the  code is structured. Naming conventions also help make your code  self-documenting, reducing the number of comments required to make the purpose  of your code clear.&lt;/p&gt; &lt;p class="docText"&gt;We present an example of a well-structured naming convention in  the following section. However, the most important thing about naming  conventions is that you pick one and use it consistently. As long as everyone  involved in a project understands the naming convention, it doesn't really  matter exactly what prefixes you use or how your names are capitalized. When it  comes to naming conventions, consistency rules, both across projects and over  time.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-4816189950870782278?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/4816189950870782278/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/06/naming-conventions.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/4816189950870782278'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/4816189950870782278'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/06/naming-conventions.html' title='Naming Conventions'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-5862073197999344858</id><published>2009-05-23T19:13:00.000-07:00</published><updated>2009-05-23T19:13:00.888-07:00</updated><title type='text'>Dictator Applications</title><content type='html'>&lt;h4 class="docSection2Title"&gt;&lt;br /&gt;&lt;/h4&gt; &lt;p class="docText"&gt;All of the architectures we have considered so far have sought  to enhance Excel in some way to improve the end user's experience when using our  application. In contrast, &lt;span class="docEmphBoldItalic"&gt;dictator  applications&lt;/span&gt; seek to completely take over the Excel user interface,  replacing Excel's menus with their own and exercising a very high level of  control over the user. In the ideal dictator application, users cannot tell they  are inside Excel.&lt;a name="ch02index43"&gt;&lt;/a&gt;&lt;a name="ch02index44"&gt;&lt;/a&gt;&lt;a name="ch02index45"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;These applications are created in Excel to use the features  Excel provides, but those features are entirely controlled by the application  and rarely (if ever) exposed to the user. Instead, the user interface is made up  of tightly controlled data-entry worksheets and/or userforms, designed to appear  like any other Windows application. These applications typically require large  amounts of code to be able to have that level of control, but that degree of  control enables us to write full-scale, fully functional Windows applications,  on a par with any that can be written in Visual Basic or other "mainstream"  application-development platforms. Indeed, by building our application within  Excel, we are immediately able to utilize the incredible amount of functionality  Excel provides.&lt;/p&gt; &lt;p class="docText"&gt;If there is a requirement for our dictator applications to work  in Excel 97, we are not able to have userforms and menu items available at the  same time, because userforms are always modal. We therefore have the choice to  base our user interface on using worksheets and menus, using userforms with  buttons to navigate between the forms or by building modeless forms using VB6.  Excel 2000 introduced modeless userforms, enabling us to make both userforms and  menus available and allowing us much more flexibility when deciding whether to  use a form or worksheet for the user interface. For this reason, we recommend  that, if possible, Excel 2000 should be set as the lowest-level version dictator  applications are designed to work within.&lt;/p&gt; &lt;p class="docText"&gt;As dictator applications get more and more complex, they will  often start to use functionality that only exists in the most recent versions of  Excel (such as the XML import/export introduced in Excel 2003), so youas the  designer of the applicationneed to decide what should happen if the application  is opened in an older version. If the functionality being used is a core part of  the application, it is unlikely the application will be usable at all in older  versions. If the use of the new features can be limited to a small part of the  application, it might make more sense to just disable that menu item, or provide  separate routines for older versions to use. Making use of new Excel features  will often result in compile errors if the workbook were to be opened in an  older version, so many dictator applications use a "front-loader" workbook to do  an initial version check, check whether all external dependencies (such as  Outlook) are available, and then open and run the main application workbook if  all the checks are okay. If the checks fail, we can provide meaningful error  messages to the end user (such as "This application requires Excel 2000 or above  and will not work in Excel 97").&lt;/p&gt; &lt;p class="docText"&gt;There's no escaping the fact that dictator applications are  much more complicated than either self-automated workbooks or  application-specific add-ins and will require an intermediate to advanced-level  Excel/VBA developer to create and maintain them. Although this type of  architecture can get very complicated, the complexity can be mitigated by  following the best-practices advice discussed in &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch03.html#ch03"&gt;Chapter 3&lt;/a&gt; Excel and VBA Development Best  Practices&lt;/span&gt; (general advice) and &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch06.html#ch06"&gt;Chapter 6&lt;/a&gt; Dictator Applications&lt;/span&gt; (specific  advice for dictator applications).&lt;a name="ch02index46"&gt;&lt;/a&gt;&lt;a name="ch02index47"&gt;&lt;/a&gt;&lt;a name="ch02index48"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;After the decision to build a dictator application has been  made, we have an incredible amount of flexibility in terms of physically  creating the application. The data could be stored in one or more separate  workbooks, local databases (for example, Access databases), or a central  database (for example, SQL Server). We could decide to include all the code in a  single workbook or have a small "core" add-in, with numerous little applets that  plug in to the core to provide the functionality, where each applet performs a  single, specific task. The decision will probably be a trade-off between (at  least) the following considerations:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p class="docList"&gt;A single-workbook structure is easier for a single developer to  maintain, because everything is in the one place.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;A multiple-workbook structure is easier for a team of  developers to create, because each developer can work on his own applet without  conflicting with another team member.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;If a multiple-workbook structure is built so each plug-in  applet is not loaded until it is first used, the initial opening of the core  add-in will be quicker than loading the full application of the single-workbook  structurealthough modern PCs might make that difference appear immaterial.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;A single-workbook structure must be updated in its entirety,  but the applets of a multiple-workbook structure can be updated and deployed  independently.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;The code required to implement a multiple-workbook plug-in  architecture is quite complex, and might be too complex for the intermediate VBA  developer to fully understandalthough we explain it in &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch11.html#ch11"&gt;Chapter 11&lt;/a&gt;  Interfaces&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a name="ch02lev3sec3"&gt;&lt;/a&gt; &lt;h5 class="docSection3Title"&gt;Requirements of a Dictator Application&lt;/h5&gt; &lt;p class="docText"&gt;To look and operate like a standalone Windows application, a  dictator application needs to modify many &lt;tt&gt;Application&lt;/tt&gt; properties, from  turning on &lt;tt&gt;IgnoreOtherApplications&lt;/tt&gt; (so double-clicking an XLS file in  Explorer will not use our instance of Excel) to turning off  &lt;tt&gt;ShowWindowsInTaskBar&lt;/tt&gt; in Excel 2000 and above (because we may have  multiple workbooks to be managed under program control), as well as hiding all  the command bars. Unfortunately, Excel will remember many of those settings, to  reuse them the next time Excel is started, so every dictator application must  start by recording the existing state of all the settings that will be changed  and restore them all when it closes. If the code to do this is written as two  separate routines and assigned shortcut keys, they also provide an easy way to  switch between the application's display and Excel's during development.&lt;a name="ch02index49"&gt;&lt;/a&gt;&lt;a name="ch02index50"&gt;&lt;/a&gt;&lt;a name="ch02index51"&gt;&lt;/a&gt;&lt;a name="ch02index52"&gt;&lt;/a&gt;&lt;a name="ch02index53"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;After a snapshot of the user's settings has been taken, the  dictator application can set the application properties it requires; it then  needs to lock down Excel to prevent users from doing things we do not want them  to do, including the following:&lt;a name="ch02index54"&gt;&lt;/a&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p class="docList"&gt;Hiding and disabling all the command bars (including the  shortcut command bars), then setting up our own.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Protecting our command bars and disabling access to the command  bar customization dialog.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Disabling all the shortcut key combinations that Excel  provides, and then optionally re-enabling the few we want to be exposed to the  user.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Setting &lt;tt&gt;Application.EnableCancelKey&lt;/tt&gt; to  &lt;tt&gt;xlDisabled&lt;/tt&gt; at the start of every entry point, to prevent users stopping  the code.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;When using worksheets as data-entry forms, we don't want the  user to be able to copy and paste entire cells, because that includes the  formatting, data validation, and so on. Therefore we need to turn off drag and  drop (which does a cut and paste); trap both Ctrl+X and Shift+Delete to do a  copy rather than a cut; and trap Ctrl+V, Shift+Insert, and the Enter keys to  ensure we only ever paste values.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p class="docText"&gt;Having locked down the Excel environment while our application  is running, we need to provide a mechanism for the developers to access the  code, to enable them to debug the application. One method is to set a global  IsDevMode Boolean variable to True if a particular file exists in the  application directory or (more securely) depending on the Windows username. This  Boolean can then be used throughout the application to provide access points,  such as enabling the Alt+F11 shortcut to switch to the VBE, adding a Reset menu  item and/or shortcut key to switch back to the Excel environment and not setting  the &lt;tt&gt;EnableCancelKey&lt;/tt&gt; property, to allow the developer to break into the  code. The Boolean can also be used within error handlers, to control whether to  display a user- or developer-oriented error message.&lt;a name="ch02index55"&gt;&lt;/a&gt;&lt;/p&gt;&lt;a name="ch02lev3sec4"&gt;&lt;/a&gt; &lt;h5 class="docSection3Title"&gt;Structure of a Dictator Application&lt;/h5&gt; &lt;p class="docText"&gt;A typical dictator application uses the following logical  structure:&lt;a name="ch02index56"&gt;&lt;/a&gt;&lt;a name="ch02index57"&gt;&lt;/a&gt;&lt;a name="ch02index58"&gt;&lt;/a&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p class="docList"&gt;A front-loader/startup routine to perform version and  dependency checks and so on&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;A main "core" set of routines, to do the following:&lt;/p&gt; &lt;p class="docList"&gt;Take a snapshot of the Excel environment settings and to  restore those settings&lt;/p&gt; &lt;p class="docList"&gt;Configure and lock down the Excel application&lt;/p&gt; &lt;p class="docList"&gt;Create and remove the application's command bars&lt;/p&gt; &lt;p class="docList"&gt;Handle copying and pasting data within the worksheet  templates&lt;/p&gt; &lt;p class="docList"&gt;Provide a library of common helper routines and classes&lt;/p&gt; &lt;p class="docList"&gt;(Optionally) Implement a plug-in architecture using class  modules, as described in &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch11.html#ch11"&gt;Chapter 11&lt;/a&gt; Interfaces&lt;/span&gt;&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;A backdrop worksheet, to display within the Excel window while  userforms are being shown, usually with some form of application-specific logo  (if we are primarily using forms for the user interface)&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Multiple independent applets that provide the application's  functionality&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Multiple template worksheets used by the applets, such as  data-entry forms or preformatted report templates&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-5862073197999344858?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/5862073197999344858/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/05/dictator-applications.html#comment-form' title='1 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/5862073197999344858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/5862073197999344858'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/05/dictator-applications.html' title='Dictator Applications'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-4939987287900736923</id><published>2009-05-22T19:12:00.000-07:00</published><updated>2009-05-22T19:12:01.652-07:00</updated><title type='text'>Application-Specific Add-ins</title><content type='html'>&lt;h4 class="docSection2Title"&gt;&lt;br /&gt;&lt;/h4&gt; &lt;p class="docText"&gt;As mentioned previously, the main problem with both codeless  and self-automated workbooks is that the "program" is physically stored in the  same file as the data the end user types in or otherwise works with. It is very  difficult to reliably update the program part of those workbooks without  affecting or in most cases destroying the end-user's work. The alternative is to  structure the application such that all the code is contained within one  workbook, with a separate workbook for the end user to use for data entry,  analysis, and so forth. One such architecture is that of an application-specific  add-in. These are very similar to normal add-ins, but instead of immediately  setting up their menu items, keyboard hooks, and so on, they stay invisible  until the user opens a workbook the add-in can identify as one for which it  should make itself available.&lt;a name="ch02index35"&gt;&lt;/a&gt;&lt;a name="ch02index36"&gt;&lt;/a&gt;&lt;a name="ch02index37"&gt;&lt;/a&gt;&lt;a name="ch02index38"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;Typically, the user would be supplied with at least two  workbooksthe XLA add-in workbook and a template workbook to use for data entry.  The template workbook(s) will contain some kind of indicator the add-in can use  to identify it, usually either a hidden defined name or a custom document  property.&lt;/p&gt; &lt;p class="docText"&gt;The key benefit of using an application-specific add-in is that  we can safely distribute updates to the code, knowing we will not be destroying  the user's data. There is, however, a small price to pay for this  convenience:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p class="docList"&gt;Splitting the application into two (or more) workbooks makes it  slightly harder to manage, because we have to keep the correct versions of both  workbooks synchronized during the development process. Simple version control is  discussed in more detail in &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch03.html#ch03"&gt;Chapter 3&lt;/a&gt; Excel and VBA Development Best  Practices&lt;/span&gt;.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;The application is slightly harder for other developers to  understandparticularly if they are used to single-workbook applications or do  not understand the technique of using class modules to hook application-level  events, as explained in &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch07.html#ch07"&gt;Chapter 7&lt;/a&gt; Using Class Modules to Create  Objects&lt;/span&gt;.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Deployment is more complicated because we need to distribute  multiple files. Deployment strategies are discussed i&lt;span class="docEmphasis"&gt;n  &lt;a class="docLink" href="ch24.html#ch24"&gt;Chapter 24&lt;/a&gt; &lt;a class="docLink" href="ch24.html#ch24"&gt;Providing Help, Securing, Packaging, and  Distributing&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a name="ch02lev3sec2"&gt;&lt;/a&gt; &lt;h5 class="docSection3Title"&gt;Structure of an Application-Specific Add-in&lt;/h5&gt; &lt;p class="docText"&gt;Application-specific add-ins are very similar in structure to  general-purpose add-ins, but with extra code to identify when to enable or  disable the menu items:&lt;a name="ch02index39"&gt;&lt;/a&gt;&lt;a name="ch02index40"&gt;&lt;/a&gt;&lt;a name="ch02index41"&gt;&lt;/a&gt;&lt;a name="ch02index42"&gt;&lt;/a&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p class="docList"&gt;A class module used to trap the application-level events.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Code in an Auto_Open or Workbook_Open routine adds the add-in's  menu items. Each menu item has its OnAction property set to call the appropriate  routine in the add-in file, but they are all initially either disabled or  hidden. It then creates an instance of the class module and initializes  application event hooks.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Separate routines for each menu item, located in a standard  module.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;(Optionally) Public functions, located in a standard module,  exposed for use in worksheet functions.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Code in the class module hooks the application-level Workbook  Activate event, checks whether the new workbook has the correct custom document  property, and if so enables the menu items and sets up the keyboard hooks.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Code in the class module hooks the application-level Workbook  Deactivate event, disables the menu items, and removes the keyboard hooks.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Code in an Auto_Close or Workbook_Close routine removes the  add-in's menu items.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-4939987287900736923?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/4939987287900736923/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/05/application-specific-add-ins.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/4939987287900736923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/4939987287900736923'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/05/application-specific-add-ins.html' title='Application-Specific Add-ins'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-494689642945918771</id><published>2009-05-21T19:11:00.000-07:00</published><updated>2009-05-21T19:11:00.414-07:00</updated><title type='text'>Function and General-Purpose Add-ins</title><content type='html'>&lt;h4 class="docSection2Title"&gt;&lt;br /&gt;&lt;/h4&gt; &lt;p class="docText"&gt;An &lt;span class="docEmphBoldItalic"&gt;add-in&lt;/span&gt; is a specific  type of application, usually used to add features to Excel. The worksheets in an  add-in are hidden from the user, so they never interact directly with the  workbook. Instead, the add-in exposes its routines by adding items to Excel's  menus and toolbars, hooking key combinations and/or exposing functions to be  used within a worksheet. The routines in an add-in can also be executed by  typing their fully qualified name (for example, MyAddin.xla!MyRoutine) in the  &lt;span class="docEmphasis"&gt;Tools &gt; Macro &gt; Macros&lt;/span&gt; dialog, although  they do not appear in the list of available macros.&lt;a name="ch02index19"&gt;&lt;/a&gt;&lt;a name="ch02index20"&gt;&lt;/a&gt;&lt;a name="ch02index21"&gt;&lt;/a&gt;&lt;a name="ch02index22"&gt;&lt;/a&gt;&lt;a name="ch02index23"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;The routines in a general-purpose add-in will always be  available to the Excel user, so they are most appropriate when used for utility  functions that are designed to work with any file, typically using the  &lt;tt&gt;ActiveWorkbook&lt;/tt&gt;, &lt;tt&gt;ActiveSheet&lt;/tt&gt; or &lt;tt&gt;Selection&lt;/tt&gt; objects to  identify the items to operate on. Care should be taken to tidily handle "user  error" issues, where the add-in's routines may be called from a context in which  they will not work. For example, if your add-in changes the case of the text in  the selected cell, you must check that there is a cell selected (and not a  drawing object, for example), it isn't locked and it isn't the result of a  formula. Similarly, if your code applies some custom formatting to the active  worksheet, you must check that there is an active sheet (because there may be no  workbooks open), it is a worksheet (and not a chart or macro sheet) and it is  not protected.&lt;a name="ch02index24"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;An add-in is just a very hidden workbook, so it doesn't appear  in the list of workbooks or the VBA &lt;tt&gt;Workbooks&lt;/tt&gt; collection, and its  macros are not listed in the &lt;span class="docEmphasis"&gt;Tools &gt; Macro &gt;  Macros&lt;/span&gt; dialog. It is, however, just like any other workbook in almost  every other way and should therefore be very easy for an intermediate Excel/VBA  developer to understand and maintain. Indeed, you can toggle between having the  workbook behave like an add-in or not by just changing the IsAddin property of  the ThisWorkbook object in the VBE's Properties window.&lt;a name="ch02index25"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;Because add-ins never expose their worksheets to the user, all  the user interaction is done through userforms (although VBA's &lt;tt&gt;InputBox&lt;/tt&gt;  and &lt;tt&gt;MsgBox&lt;/tt&gt; functions can be used in simple situations). This gives us a  high level of control over the user's entries, enabling us to create  applications that are totally robust and reliableassuming we include  data-validation code and good error handling.&lt;a name="ch02index26"&gt;&lt;/a&gt;&lt;a name="ch02index27"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;If the add-in needs to store any information, such as  remembering a user's choices, that information should be kept separate from the  add-in file, by storing it either in the registry (using &lt;tt&gt;SaveSetting/  GetSetting&lt;/tt&gt;) or in a separate file (such as an INI file). If that is done,  the add-in will never need to be saved by the end user and can be simply  replaced by a new version if an update is required.&lt;a name="ch02index28"&gt;&lt;/a&gt;&lt;a name="ch02index29"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;If you are willing to trust the end user to install the add-in  correctly, it is also very easy to deployjust send the XLA file with  instructions to either copy it to their Library folder or to use the Browse  button in the &lt;span class="docEmphasis"&gt;Tools &gt; Add-ins&lt;/span&gt; dialog to locate  the file. The alternative is to use an installation routine to write the  required registry entries Excel uses to maintain its add-ins list, such that the  add-in is automatically opened and installed when the client next starts Excel.  These registry entries are covered in detail in &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch24.html#ch24"&gt;Chapter 24&lt;/a&gt; &lt;a class="docLink" href="ch24.html#ch24"&gt;Proving Help, Securing, Packaging and  Distributing&lt;/a&gt;&lt;/span&gt;.&lt;a name="ch02index30"&gt;&lt;/a&gt;&lt;a name="ch02index31"&gt;&lt;/a&gt;&lt;a name="ch02index32"&gt;&lt;/a&gt;&lt;a name="ch02index33"&gt;&lt;/a&gt;&lt;a name="ch02index34"&gt;&lt;/a&gt;&lt;/p&gt;&lt;a name="ch02lev3sec1"&gt;&lt;/a&gt; &lt;h5 class="docSection3Title"&gt;Structure of a Function or General-Purpose  Add-in&lt;/h5&gt; &lt;p class="docText"&gt;Most general-purpose add-ins use the same structure:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p class="docList"&gt;Code in an Auto_Open or Workbook_Open routine that adds the  add-in's menu items and sets up the keyboard hooks. Each menu item has its  OnAction property set to call the appropriate routine in the add-in file.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Separate routines for each menu item, located in a standard  module.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Public functions, located in a standard module, exposed for use  in worksheet formulas. Dedicated function add-ins often contain only functions  and do not add menu items.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;Code in an Auto_Close or Workbook_Close routine that removes  the add-in's menu items and clears the keyboard hooks.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-494689642945918771?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/494689642945918771/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/05/function-and-general-purpose-add-ins.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/494689642945918771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/494689642945918771'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/05/function-and-general-purpose-add-ins.html' title='Function and General-Purpose Add-ins'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-5312784494410389372</id><published>2009-05-20T19:10:00.000-07:00</published><updated>2009-05-20T19:10:00.482-07:00</updated><title type='text'>Self-Automated Workbooks</title><content type='html'>&lt;h4 class="docSection2Title"&gt;Self-Automated Workbooks&lt;/h4&gt; &lt;p class="docText"&gt;A self-automated workbook is one in which the VBA code is  physically contained within the workbook it acts upon. Probably the most common  type of application, the automation code can be as simple as ensuring the  workbook always opens with Sheet1 active or be as complex as an entire  application. This is usually the first type of application a beginning VBA  developer produces, built by adding numerous helper routines to the workbook  that get progressively more complex (and usually cumbersome) over time.&lt;a name="ch02index10"&gt;&lt;/a&gt;&lt;a name="ch02index11"&gt;&lt;/a&gt;&lt;a name="ch02index12"&gt;&lt;/a&gt;&lt;a name="ch02index13"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;After VBA is introduced to the workbook, we have much more  flexibility in providing the required functionality and can make a considered  choice whether to use Excel's built-in functions or write our own equivalents to  avoid some of Excel's pitfalls. For example, Excel's data validation might not  fire correctly when entries are made in multiple cells at the same time and is  usually cleared when data is pasted onto the range. We can work around both  these limitations by trapping the Worksheet_Change event and performing our own  validation in code, making the worksheet more robust, reliable, and secure.&lt;/p&gt; &lt;p class="docText"&gt;The workbook and worksheet code modules are provided for us by  Excel to hook whichever events we want to use, and any ActiveX controls we add  to the worksheet are automatically exposed in the same code module. This is the  simplest architecture to create and probably the simplest to understandmost VBA  developers will have written an application of this type and will therefore  understand, for example, how the code within the worksheet code module is  triggered.&lt;/p&gt; &lt;p class="docText"&gt;The clearest advantage this style of application has over all  the others is in the ease of deployment. There is only one filethe workbookto  distribute; there is no need to install or configure anything; and because the  code is physically stored within the workbook, it is immediately available and  working as soon as the workbook is opened.&lt;/p&gt; &lt;p class="docText"&gt;Unfortunately, the self-automated workbook's clearest advantage  is also its biggest problem. Because the code is physically inside the workbook,  how do you issue updates to the code without affecting the data that has been  entered on the worksheets? Although it is possible to write VBA that modifies  the code within another workbook, the user has to specifically allow that to  happen (in Excel 2002 and above), and it is only possible to unprotect and  reprotect the VBA project using SendKeys, which cannot be relied on to work in  foreign-language versions of Excel or if Excel does not have the focus. Even if  the project could be unprotected and reprotected, saving the updated project  would remove any digital signature that had been applied, resulting in macro  virus warnings every time the workbook was subsequently opened. The only  reliable way self-automated workbooks can be updated is to provide a completely  new workbook with a routine (or instructions) to copy the data from the old  workbook.&lt;a name="ch02index14"&gt;&lt;/a&gt;&lt;a name="ch02index15"&gt;&lt;/a&gt;&lt;a name="ch02index16"&gt;&lt;/a&gt;&lt;a name="ch02index17"&gt;&lt;/a&gt;&lt;a name="ch02index18"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;Self-automated workbooks are an ideal choice if the following  conditions apply:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p class="docList"&gt;The routines contained within the workbook provide specific  functionality for that workbook (as opposed to general-purpose utilities).&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;There will only be one copy of the workbook (so any changes can  be done directly to that workbook), or&lt;/p&gt; &lt;p class="docList"&gt;The workbook will have a short lifetime and/or will be  distributed to a large (and maybe unknown) audience, in which case the ease of  deployment becomes a significant consideration, and there is no intention to  distribute any updates, or&lt;/p&gt; &lt;p class="docList"&gt;The workbook does not contain any data that will need to be  retained during an update, such as one that obtains its data from an external  data source.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-5312784494410389372?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/5312784494410389372/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/05/self-automated-workbooks.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/5312784494410389372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/5312784494410389372'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/05/self-automated-workbooks.html' title='Self-Automated Workbooks'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-101375756100935432</id><published>2009-05-19T19:09:00.001-07:00</published><updated>2009-05-19T19:09:55.496-07:00</updated><title type='text'>Codeless Applications</title><content type='html'>&lt;h4 class="docSection2Title"&gt;Codeless Applications&lt;/h4&gt; &lt;p class="docText"&gt;The most basic application is one that only uses Excel's  built-in functionality. Everybody creates this type of application without  knowing it, simply by using Excel. They are typically created by beginning to  intermediate Excel users who have not yet learned to use VBA. All the special  formatting, validation, formulas and so on are placed directly on the same  worksheet where data entry will be performed. There are some major issues with  this approach, which together mean totally codeless applications are rarely a  good choice.&lt;a name="ch02index04"&gt;&lt;/a&gt;&lt;a name="ch02index05"&gt;&lt;/a&gt;&lt;a name="ch02index06"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;Those who avoid using VBA may find that some of their worksheet  functions and data-validation criteria get extremely complex and almost  incomprehensible to anyone other than the author. The equivalent VBA will often  be easier to understand.&lt;/p&gt; &lt;p class="docText"&gt;The same worksheet is usually used for data entry, analysis,  and presentation, often resulting in a cluttered appearance (usually with  multitudes of differently colored cells to try to identify their purpose) that  is difficult to understand, is unintuitive to use and is almost impossible for  anyone except the author to modify reliably.&lt;/p&gt; &lt;p class="docText"&gt;Such applications have to rely on Excel's cell protection and  password-protecting the worksheet to prevent the users making unauthorized  changes to the formulas, validation, formatting and so on. Worksheet passwords  are notoriously easy to break, and a simple copy and paste will wipe out any  data validation that has been set up. These applications are therefore neither  secure nor robust.&lt;/p&gt; &lt;p class="docText"&gt;Without any code, we are unable to provide much assistance to  the user; we have to rely on them to do everything themselvesand do it  correctlyinstead of providing reliable helper routines that automate some of  their tasks. The more complex the application, the less likely it is that all  the tasks will be performed correctly.&lt;/p&gt; &lt;p class="docText"&gt;If we consider a definition of what constitutes a "program" to  be "anything that isn't the data," we see that all the conditional formatting,  data validation, worksheet functions and so forth are really part of the  "program," so these applications break the basic tenet of keeping the program  and data physically separate. After the end users have started to enter data  into their worksheet, it is very difficult to distribute an updated worksheet to  them, without losing the data they have already entered. In addition to the new  version of the worksheet, you would have to either provide clear instructions  explaining how to copy their data across or write a conversion program that will  copy their data from the old to the new workbook.&lt;/p&gt; &lt;p class="docText"&gt;Codeless applications are ideal for simple situations where  most of the following conditions apply:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p class="docList"&gt;There will only be one copy of the workbook (so any changes can  be done directly to that workbook), or each copy of the workbook will have a  short lifetime, such as a survey or data-collection form that can be forgotten  about after it has been completed and returned. In each case, the assumption is  that the workbooks will not need up dating after they have been deployed.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;The end users will be maintaining the workbook themselves (and  don't know VBA), or the workbook will not require any maintenance at all.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;The workbook might be copied and updated on different machines  (although only one at a time), such as when the workbook is taken home for the  weekendbecause it is self-contained, it can easily be copied to a floppy disk or  e-mailed.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;There are relatively few routine or complex tasks to be  performed to maintain or analyze the data.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;There are only a small number of end users, who can be well  trained to ensure the application is used correctly and is not inadvertently  broken.&lt;a name="ch02index07"&gt;&lt;/a&gt;&lt;a name="ch02index08"&gt;&lt;/a&gt;&lt;a name="ch02index09"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p class="docText"&gt;A good example of a codeless application is a simple survey or  data-collection form that requires the end user to fill in the details and  e-mail the completed workbook to a central address for consolidation and  analysis. The main benefit of a codeless application in such a situation is the  avoidance of Excel's macro security warnings and the corresponding assurance  that there is nothing malicious in the file.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-101375756100935432?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/101375756100935432/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/05/codeless-applications.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/101375756100935432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/101375756100935432'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/05/codeless-applications.html' title='Codeless Applications'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-7285391434153503441</id><published>2009-05-15T18:20:00.000-07:00</published><updated>2009-05-15T18:21:02.126-07:00</updated><title type='text'>Excel as an Application Development Platform</title><content type='html'>&lt;p class="docText"&gt;If we look at Excel as a development platform and not just a  spreadsheet, we can break it down into five fundamental components we can use  for our applications:&lt;/p&gt; &lt;ul&gt;&lt;li&gt; &lt;p class="docList"&gt;The worksheet, charts and so on, used as a user interface and  presentation layer for data entry and reporting&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;The worksheet, used as a simple data store for lists, tables  and other information used by our application&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;VBA, Excel's programming language and forms engine&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;The worksheet, used as a declarative programming language for  high-performance numeric processing&lt;a name="ch01index11"&gt;&lt;/a&gt;&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docList"&gt;The Excel object model, allowing programmatic control of  (nearly) all of Excel's functionality, from both within Excel and from outside  it&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a name="ch01lev2sec1"&gt;&lt;/a&gt; &lt;h4 class="docSection2Title"&gt;The Worksheet as a Presentation Layer for Data Entry  and Reporting&lt;/h4&gt; &lt;p class="docText"&gt;When most people think about Excel, they think in terms of  typing numbers into cells, having some calculations update and seeing a result  displayed in a different cell or on a chart. Without necessarily thinking in  such terms, they are using the worksheet as a user interface for their data  entry and reporting and are generally comfortable with these tasks. The in-cell  editing, validation and formatting features built in to Excel provide an  extremely rich and compelling data-entry experience, while the charting, cell  formatting and drawing tools provide a presentation-quality reporting mechanism.  It is hard to imagine the code that would be required if we tried to reproduce  the experience using the form design tools available in most other development  environments, yet it's there waiting for us to use in our Excel-based  applications. The biggest problem we face is how to add some structure to the  free-form grid of the worksheet, to present a simple and easy-to-use interface,  while leveraging the rich functionality Excel provides. &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch04.html#ch04"&gt;Chapter 4&lt;/a&gt; Worksheet  Design&lt;/span&gt; introduces some techniques and best practices for developing  worksheet-based data-entry forms, and &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch15.html#ch15"&gt;Chapter 15&lt;/a&gt; Advanced Charting Techniques&lt;/span&gt;  discusses using Excel's charting capabilities.&lt;/p&gt;&lt;a name="ch01lev2sec2"&gt;&lt;/a&gt; &lt;h4 class="docSection2Title"&gt;The Worksheet as a Simple Data Store&lt;/h4&gt; &lt;p class="docText"&gt;What is a worksheet when it is never intended to be shown to  the end user? At its simplest, it is no more than a large grid of cells in which  we can store just about anything we want tonumbers, text, lists, tables or  pictures. Most applications use some amount of static data or textual or  graphical resources; storing that information in a worksheet makes it both  extremely easy to access using VBA and simple to maintain. Lists and tables in  worksheets can directly feed Excel's data validation (as shown in &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch04.html#ch04"&gt;Chapter 4&lt;/a&gt; Worksheet  Design&lt;/span&gt;), greatly simplify the creation and maintenance of command bars  (&lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch08.html#ch08"&gt;Chapter 8&lt;/a&gt;  Advanced Command Bar Handling&lt;/span&gt;), and enable us to construct dynamic  userforms (&lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch10.html#ch10"&gt;Chapter 10&lt;/a&gt; Userform Design and Best  Practices&lt;/span&gt;).&lt;a name="ch01index12"&gt;&lt;/a&gt;&lt;/p&gt;&lt;a name="ch01lev2sec3"&gt;&lt;/a&gt; &lt;h4 class="docSection2Title"&gt;VBA: Excel's Programming Language&lt;/h4&gt; &lt;p class="docText"&gt;We expect most readers of this book to have at least some  familiarity with VBA. If not, we suggest you read either our &lt;span class="docEmphasis"&gt;Excel 2000/2002 VBA Programmer's Reference&lt;/span&gt; or John  Walkenbach's &lt;span class="docEmphasis"&gt;Excel Power Programming&lt;/span&gt; before  continuing much further. Many people see the &lt;span class="docEmphasis"&gt;A&lt;/span&gt; in  VBA as meaning the language is somehow less than Visual Basic itself. In fact,  both VB6 and Office 2000 and above use exactly the same DLL to provide the  keywords, syntax and statements we program with. The only differences are the  objects provided by the runtimes (the VB runtime vs. the Excel objects), the  forms packages (VB's "Ruby" forms vs. Office UserForms) and that VB6 includes a  compiler to create EXEs and DLLs, whereas VBA is always interpreted at runtime.  Indeed, the Office Developer Edition (pre-Excel 2003) includes the same compiler  VB6 uses, enabling us to compile (simple) DLLs from within the Office Visual  Basic Editor.&lt;a name="ch01index13"&gt;&lt;/a&gt;&lt;a name="ch01index14"&gt;&lt;/a&gt;&lt;a name="ch01index15"&gt;&lt;/a&gt;&lt;a name="ch01index16"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;Most beginner and intermediate VBA developers use VBA as a  &lt;span class="docEmphBoldItalic"&gt;purely&lt;/span&gt; procedural language, with nearly all  their code residing in standard modules. VBA also enables us to create  applications using an object-oriented programming (OOP) approach, in which class  modules are used to create our own objects. &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch07.html#ch07"&gt;Chapter 7&lt;/a&gt; Using Class Modules to Create  Objects&lt;/span&gt; and &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch11.html#ch11"&gt;Chapter 11&lt;/a&gt; Interfaces&lt;/span&gt; explain how to use VBA in  this manner, while basic OOP concepts (such as encapsulation) are used  throughout the book.&lt;a name="ch01index17"&gt;&lt;/a&gt;&lt;a name="ch01index18"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;Most of this book is dedicated to explaining advanced VBA  techniques and a professional approach to application design and development  that can put using VBA in Excel on a par with, and sometimes in front of, using  VB6 or VB.Net for application development. We also show in &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch20.html#ch20"&gt;Chapter 20&lt;/a&gt;  Combining Excel and Visual Basic 6&lt;/span&gt; and &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch22.html#ch22"&gt;Chapter 22&lt;/a&gt; Using VB.NET and the Visual  Studio Tools for Office&lt;/span&gt; that the Excel developer can use the best of both  worlds, by combining Excel, VB6 and/or VB.Net in a seamless application.&lt;/p&gt;&lt;a name="ch01lev2sec4"&gt;&lt;/a&gt; &lt;h4 class="docSection2Title"&gt;The Worksheet as a Declarative Programming  Language&lt;/h4&gt; &lt;p class="docText"&gt;Consider the following code:&lt;/p&gt;&lt;pre&gt;dSales = 1000&lt;br /&gt;dPrice = 10.99&lt;br /&gt;dRevenue = dSales * dPrice&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="docText"&gt;This code could quite easily be a few lines of VBA. We give the  variable &lt;tt&gt;dSales&lt;/tt&gt; a value of &lt;tt&gt;1000&lt;/tt&gt;, the variable &lt;tt&gt;dPrice&lt;/tt&gt;  a value of &lt;tt&gt;10.99&lt;/tt&gt; and then calculate the revenue as sales times price.  If we change the names of the variables and adjust the spacing, the same code  could also be written as follows:&lt;a name="ch01index19"&gt;&lt;/a&gt;&lt;/p&gt;&lt;pre&gt;D1   =1000&lt;br /&gt;D2   =10.99&lt;br /&gt;D3   =D1*D2&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="docText"&gt;This preceding code looks much more like worksheet cell  addresses and formulas than lines of VBA code, showing that a worksheet is in  fact a programming language of its own, if we choose to think of it in those  terms. The IF() worksheet function is directly equivalent to the  &lt;tt&gt;If...Then...Else&lt;/tt&gt; VBA statement, and the judicious use of circular  references and iteration can be equivalent to either the &lt;tt&gt;For...Next&lt;/tt&gt; or  &lt;tt&gt;Do...Loop&lt;/tt&gt; structures.&lt;/p&gt; &lt;p class="docText"&gt;Instead of stating a set of &lt;span class="docEmphBoldItalic"&gt;operations&lt;/span&gt; that are executed line by line, we  "program" in this language by stating a set of &lt;span class="docEmphBoldItalic"&gt;declarations&lt;/span&gt; (by typing formulas and values into  worksheet cells), in any order we want to:&lt;a name="ch01index20"&gt;&lt;/a&gt;&lt;a name="ch01index21"&gt;&lt;/a&gt;&lt;/p&gt;&lt;pre&gt;"D3 is the product of D1 and D2"&lt;br /&gt;"D1 has the value 1000"&lt;br /&gt;"D2 has the value 10.99"&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p class="docText"&gt;To "run" this program, Excel first examines all the  declarations and builds a "precedence tree" to identify which cells depend on  the results of which other cells and thereby determine the most efficient order  in which the cells must be calculated. The same precedence tree is also used to  identify the minimum set of calculations that must be performed whenever the  value in a cell is changed. The result is a calculation engine that is vastly  more efficient than an equivalent VBA program, and one that should be used  whenever complex numeric computations are required in our applications.&lt;a name="ch01index22"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;Microsoft Excel (and other spreadsheet programs) is unique  among application development platforms in providing both a procedural (VBA) and  a declarative (the worksheet) programming language. The most efficient Excel  application is one that makes appropriate use of both these languages.&lt;/p&gt; &lt;p class="docText"&gt;It is assumed the reader of this book has some knowledge of  Excel and worksheet functions, so &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch14.html#ch14"&gt;Chapter 14&lt;/a&gt; Data Manipulation Techniques&lt;/span&gt; focuses  on using advanced worksheet functions (including best-practice suggestions for  handling circular references) and Excel's other data-analysis features.&lt;/p&gt;&lt;a name="ch01lev2sec5"&gt;&lt;/a&gt; &lt;h4 class="docSection2Title"&gt;The Excel Object Model&lt;/h4&gt; &lt;p class="docText"&gt;Although the other four components of the Excel platform are  invaluable in the development of applications, it is probably the richness of  the Excel object model that provides the most compelling reason to base our  application development on Excel. Almost everything that can be done through the  user interface can also be done programmatically by using the objects in the  Excel object modelaccessing the list of number formats and applying a digital  signature to a workbook are perhaps the most notable exceptions. The vast array  of functionality exposed by these objects makes highly complex applications  fairly simple to developit becomes more an issue of when and how to efficiently  plug the functionality together than to develop the functionality from scratch.  This book does not attempt to explore and document all the backwaters of the  object model, but instead makes continual use of the objects in our application  development.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-7285391434153503441?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/7285391434153503441/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/05/excel-as-application-development.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/7285391434153503441'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/7285391434153503441'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/05/excel-as-application-development.html' title='Excel as an Application Development Platform'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-1137477987784202530</id><published>2009-05-15T18:19:00.000-07:00</published><updated>2009-05-15T18:20:03.046-07:00</updated><title type='text'>The Excel Developer</title><content type='html'>&lt;p class="docText"&gt;Excel developers can be divided into five general categories,  based on their experience and knowledge of Excel and VBA. To varying degrees,  this book has something to offer each of them, but with a focus on the more  advanced topics. Putting yourself into one of these categories might help you  decide whether this is the right book for you.&lt;a name="ch01index03"&gt;&lt;/a&gt;&lt;a name="ch01index04"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;The basic &lt;span class="docEmphBoldItalic"&gt;Excel user&lt;/span&gt;  probably doesn't think of himself as a developer at all. To basic users, Excel  is no more than a tool to help them get on with their job. They start off using  Excel worksheets as a handy place to store lists or perform simple repetitive  calculations. As they discover more of Excel's functionality, their workbooks  become more complex and start to include lots of worksheet functions, pivot  tables and charts. There is little in this book for these people; although &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch04.html#ch04"&gt;Chapter 4&lt;/a&gt; Worksheet  Design&lt;/span&gt; details the best practices to use when designing and laying out a  worksheet for data entry, &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch14.html#ch14"&gt;Chapter 14&lt;/a&gt; Data Manipulation Techniques&lt;/span&gt;  explains how to structure a worksheet and which functions and features to use to  manipulate their lists, and &lt;span class="docEmphasis"&gt;&lt;a class="docLink" href="ch15.html#ch15"&gt;Chapter 15&lt;/a&gt; Advanced Charting Techniques&lt;/span&gt;,  explains how to get the most from Excel's chart engine. The techniques suggested  in these chapters should help the basic Excel user avoid some of the pitfalls  often encountered as their experience and the complexity of their spreadsheets  increases.&lt;/p&gt; &lt;p class="docText"&gt;The &lt;span class="docEmphBoldItalic"&gt;Excel power user&lt;/span&gt; has a  wide understanding of Excel's functionality, knows which tool or function is  best to use in a given situation, creates complex spreadsheets for his own use  and is often called on to help develop colleagues' spreadsheets or to identify  why colleagues' spreadsheets do not work as intended. Occasionally power users  include small snippets of VBA they found on the Internet or created using the  macro recorder, but struggle to adapt the code to their needs. As a result, they  produce code that is untidy, slow and hard to maintain. Although this book is  not a VBA tutorial, the power user has much to gain from following the best  practices we suggest for both worksheets and code modules. Most of the chapters  in the book are relevant to power users who have an interest in improving their  Excel and VBA development skills.&lt;a name="ch01index05"&gt;&lt;/a&gt;&lt;a name="ch01index06"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;The &lt;span class="docEmphBoldItalic"&gt;VBA developer&lt;/span&gt; makes  extensive use of VBA code in his workbooks (often too much). VBA developers are  typically either power users who have started to learn VBA too early or Visual  Basic 6 developers who have switched to Excel VBA development. Although they  might be very proficient at VBA, they believe every problem must have a VBA  solution and lack sufficient knowledge of Excel to make the best use of its  features. Their solutions are often cumbersome, slow and make poor use of  Excel's object model. This book has much to offer VBA developers to improve  their use of Excel itself, including explaining how to architect Excel-based  applications, the best practices for designing worksheets and how to use Excel's  features for their data entry, analysis and presentation. This book also seeks  to improve their Excel VBA development skills by introducing advanced coding  techniques, detailing VBA best practices and explaining how to improve their  code's performance.&lt;a name="ch01index07"&gt;&lt;/a&gt;&lt;a name="ch01index08"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p class="docText"&gt;The &lt;span class="docEmphBoldItalic"&gt;Excel developer&lt;/span&gt; has  realized the most efficient and maintainable applications are those that make  the most of Excel's own functionality, augmented by VBA when appropriate. Excel  developers are confident developing Excel-based applications for their  colleagues to use or as part of an in-house development team. Their undoubted  knowledge of Excel is put to good use in their applications, but it also  constrains their designs, and they are reluctant to use other languages and  applications to augment their Excel solutions. They have probably read John  Walkenbach's &lt;span class="docEmphasis"&gt;Excel Power Programming&lt;/span&gt; and/or our  own &lt;span class="docEmphasis"&gt;Excel 2000/2002 VBA Programmer's Reference&lt;/span&gt;  and need a book to take them to the highest level of Excel application  developmentthat of the professional developer. This is that book.&lt;/p&gt; &lt;p class="docText"&gt;The &lt;span class="docEmphBoldItalic"&gt;professional Excel  developer&lt;/span&gt; designs and develops Excel-based applications and utilities for  clients or employers that are robust, fast, easy to use, maintainable and  secure. Excel forms the core of their solutions, but they include any other  applications and languages that are appropriate. For example, they might use  third-party ActiveX controls; automate other applications; use Windows API  calls; use ADO to connect to external databases, C/C++ for fast custom worksheet  functions, VB6 or VB.Net for creating their own object models and securing their  code; and XML for sharing data over the Internet. This book teaches all those  skills. If you are already a professional Excel developer, you know that  learning never stops and will appreciate the knowledge and best practices  presented in this book by three of your peers.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-1137477987784202530?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/1137477987784202530/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/05/excel-developer.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/1137477987784202530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/1137477987784202530'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/05/excel-developer.html' title='The Excel Developer'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-2032415314914515202</id><published>2009-01-15T18:25:00.000-08:00</published><updated>2009-05-15T18:26:54.409-07:00</updated><title type='text'>Repairing corrupted files in Excel</title><content type='html'>&lt;table class="collapse"&gt;&lt;tbody&gt;&lt;tr class="trbgeven"&gt;&lt;th&gt;Applies to&lt;/th&gt; &lt;/tr&gt; &lt;tr class="trbgodd"&gt; &lt;td&gt;Microsoft Office Excel 2003&lt;br /&gt;Microsoft Excel 2002&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;Microsoft Excel provides automatic recovery for a corrupted file by attempting to reopen and simultaneously repair the file. Excel identifies what it changed while repairing the file. If the repair fails, Excel again tries to open the file but instead of attempting a repair, Excel extracts cell values and formulas leaving only the data. Under some circumstances, however, Excel won't automatically go into recovery mode, so users may find it necessary to recover file data manually.&lt;/p&gt; &lt;h3&gt;To manually repair a file&lt;/h3&gt; &lt;ol&gt;&lt;li&gt;On the &lt;b class="ui"&gt;File&lt;/b&gt; menu, click &lt;b class="ui"&gt;Open&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;In the &lt;b class="bterm"&gt;Open&lt;/b&gt; dialog box, select the file you want to open, and click the arrow next to the &lt;b class="ui"&gt;Open&lt;/b&gt; button.&lt;/li&gt;&lt;li&gt;Click &lt;b class="bterm"&gt;Open and Repair&lt;/b&gt;, and then choose which method you want to use to recover your workbook.&lt;/li&gt;&lt;/ol&gt;&lt;h2 id=""&gt;Methods for recovering data from damaged workbooks&lt;/h2&gt; &lt;p&gt;The following are additional methods you can use to recover data manually from a file that has been corrupted. Under some circumstances a disk error or network error may make it impossible to open a file. In those situations you should move your file to a different hard disk drive or from the network to a local disk before spending time implementing the recovery options outlined here. &lt;/p&gt; &lt;p&gt;The following methods are opportunities to save data that might otherwise be lost, so if one method is not successful, try another. You can also try third-party software solutions to recover file data if you can't recover your data using these methods.&lt;/p&gt; &lt;h3&gt;If you can open the file in Excel&lt;/h3&gt; &lt;div class="alert"&gt; &lt;p&gt;&lt;a class="DropDown" href="javascript:ToggleDiv('divExpCollAsst_1')"&gt;&lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA790050001033" alt="Show" id="divExpCollAsst_1_img" border="0" /&gt;Use the Revert To Saved Document command&lt;/a&gt;&lt;/p&gt;  &lt;span class="ACECollapsed" border="0" id="divExpCollAsst_1"&gt;If you are editing a Microsoft Excel worksheet and the file becomes corrupted before you have saved changes to the file, you can recover the original worksheet by doing the following: &lt;ol&gt;&lt;li&gt;On the &lt;b class="ui"&gt;File&lt;/b&gt; menu, click &lt;b class="ui"&gt;Open&lt;/b&gt; and select the name of the file that you are editing.    &lt;p&gt;A dialog box appears with the message "Revert to Saved Document?"&lt;/p&gt; &lt;/li&gt;&lt;li&gt;Click &lt;b class="bterm"&gt;OK&lt;/b&gt;. The file you are editing reverts to the last saved version of the file.&lt;/li&gt;&lt;/ol&gt; &lt;/span&gt;&lt;/div&gt; &lt;div class="alert"&gt; &lt;p&gt;&lt;a class="DropDown" href="javascript:ToggleDiv('divExpCollAsst_2')"&gt;&lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA790050001033" alt="Show" id="divExpCollAsst_2_img" border="0" /&gt;Save the file in SYLK format&lt;/a&gt;&lt;/p&gt;  &lt;span class="ACECollapsed" border="0" id="divExpCollAsst_2"&gt; &lt;p&gt;Saving the file in SYLK format is typically used to remove printer corruption. If you can open the corrupted Microsoft Excel file, you can "filter" it if you save it in SYLK format, close the file, and then reopen it as follows:&lt;/p&gt;  &lt;ol&gt;&lt;li&gt;On the &lt;b class="ui"&gt;File&lt;/b&gt; menu, click &lt;b class="bterm"&gt;Save As&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;In the &lt;b class="bterm"&gt;Save as type&lt;/b&gt; list, click &lt;b class="bterm"&gt;SYLK (Symbolic Link)&lt;/b&gt;, and then click &lt;b class="ui"&gt;Save&lt;/b&gt;. &lt;p&gt;&lt;b class="cntnote"&gt; Note &lt;/b&gt;  Only the active sheet in the workbook is saved when you use the SYLK file format. Click &lt;b class="bterm"&gt;OK&lt;/b&gt; when the message tells you the selected file type does not support workbooks. Click &lt;b class="bterm"&gt;Yes&lt;/b&gt; when the message tells you the file may contain features that aren't compatible with the SYLK format.&lt;/p&gt; &lt;/li&gt;&lt;li&gt;On the &lt;b class="ui"&gt;File&lt;/b&gt; menu, click &lt;b class="ui"&gt;Close&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;On the &lt;b class="ui"&gt;File&lt;/b&gt; menu, click &lt;b class="ui"&gt;Open&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;Select the .slk file you saved, and click &lt;b class="bterm"&gt;Open.&lt;/b&gt;&lt;p&gt;&lt;b class="cntnote"&gt; Note &lt;/b&gt;  To see the .slk file, you may need to click &lt;b class="bterm"&gt;All Files&lt;/b&gt; in the &lt;b class="bterm"&gt;Files of type&lt;/b&gt; list.&lt;/p&gt; &lt;/li&gt;&lt;li&gt;On the &lt;b class="ui"&gt;File&lt;/b&gt; menu, click &lt;b class="bterm"&gt;Save As&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;In the &lt;b class="bterm"&gt;Save as type&lt;/b&gt; box, click &lt;b class="bterm"&gt;Microsoft Excel Workbook&lt;/b&gt;, and then click &lt;b class="ui"&gt;Save&lt;/b&gt;.&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;&lt;b class="cntnote"&gt; Note &lt;/b&gt;  Because this format saves only the active worksheet, you must open the corrupted file repeatedly and save each worksheet separately.&lt;/p&gt; &lt;/span&gt;&lt;/div&gt; &lt;div class="alert"&gt; &lt;p&gt;&lt;a class="DropDown" href="javascript:ToggleDiv('divExpCollAsst_3')"&gt;&lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA790050001033" alt="Show" id="divExpCollAsst_3_img" border="0" /&gt;Save the file in Hypertext Markup Language (HTML) format&lt;/a&gt;&lt;/p&gt;  &lt;span class="ACECollapsed" border="0" id="divExpCollAsst_3"&gt;If you can open the corrupted Microsoft Excel file, you can "filter" it if you save it in HTML format, close the file, and then reopen it as follows: &lt;ol&gt;&lt;li&gt;On the &lt;b class="ui"&gt;File&lt;/b&gt; menu, click &lt;b class="bterm"&gt;Save As&lt;/b&gt;. In the &lt;b class="bterm"&gt;Save as type&lt;/b&gt; list, click &lt;b class="bterm"&gt;Web Page (*.htm, *.html)&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;Under &lt;b class="bterm"&gt;Save&lt;/b&gt;, click &lt;b class="bterm"&gt;Entire Workbook&lt;/b&gt;, and then click &lt;b class="ui"&gt;Save&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;Close the file.&lt;/li&gt;&lt;li&gt;Open the file again in Excel.&lt;/li&gt;&lt;li&gt;On the &lt;b class="ui"&gt;File&lt;/b&gt; menu, click &lt;b class="bterm"&gt;Save As&lt;/b&gt;. In the &lt;b class="bterm"&gt;Save as type&lt;/b&gt; list, click &lt;b class="bterm"&gt;Microsoft Excel Workbook&lt;/b&gt;. Change the name of the file to create a new "filtered" copy without replacing the original.&lt;/li&gt;&lt;/ol&gt;  &lt;p&gt;&lt;b class="cntnote"&gt; Note &lt;/b&gt;  Some features may be lost when you save in HTML format.&lt;/p&gt;&lt;/span&gt;&lt;/div&gt; &lt;h3&gt;If you can't open the file in Excel&lt;/h3&gt; &lt;div class="alert"&gt; &lt;p&gt;&lt;a class="DropDown" href="javascript:ToggleDiv('divExpCollAsst_4')"&gt;&lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA790050001033" alt="Show" id="divExpCollAsst_4_img" border="0" /&gt;Set the recalculation option in Excel to manual&lt;/a&gt;&lt;/p&gt;  &lt;span class="ACECollapsed" border="0" id="divExpCollAsst_4"&gt; &lt;ol&gt;&lt;li&gt;Start Excel and open a blank workbook if one is not open on the screen.&lt;/li&gt;&lt;li&gt;On the &lt;b class="ui"&gt;Tools&lt;/b&gt; menu, click &lt;b class="ui"&gt;Options&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;Click the &lt;b class="ui"&gt;Calculation&lt;/b&gt; tab.&lt;/li&gt;&lt;li&gt;In the &lt;b class="bterm"&gt;Calculation&lt;/b&gt; section, click &lt;b class="ui"&gt;Manual&lt;/b&gt;, and then click &lt;b class="ui"&gt;OK&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;On the &lt;b class="ui"&gt;File&lt;/b&gt; menu, click &lt;b class="ui"&gt;Open&lt;/b&gt; and try to open the file.&lt;/li&gt;&lt;/ol&gt; &lt;/span&gt;&lt;/div&gt; &lt;div class="alert"&gt; &lt;p&gt;&lt;a class="DropDown" href="javascript:ToggleDiv('divExpCollAsst_5')"&gt;&lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA790050001033" alt="Show" id="divExpCollAsst_5_img" border="0" /&gt;Use external references to link to the corrupted file&lt;/a&gt;&lt;/p&gt;  &lt;span class="ACECollapsed" border="0" id="divExpCollAsst_5"&gt; &lt;p&gt;This method retrieves only data and not formulas or values from the workbook.&lt;/p&gt;  &lt;ol&gt;&lt;li&gt;On the &lt;b class="ui"&gt;File&lt;/b&gt; menu, click &lt;b class="ui"&gt;Open&lt;/b&gt;. Then, browse from the current folder to the folder that contains the damaged file, and click &lt;b class="ui"&gt;Cancel&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;Click &lt;b class="bterm"&gt;New&lt;/b&gt; on the &lt;b class="ui"&gt;File&lt;/b&gt; menu, click &lt;b class="ui"&gt;File&lt;/b&gt;, and then click &lt;b class="ui"&gt;OK&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;Type &lt;b class="bterm"&gt;=&lt;i&gt;File Name&lt;/i&gt;!A1&lt;/b&gt; in cell A1 of the new workbook, where &lt;b class="bterm"&gt;&lt;i&gt;File Name&lt;/i&gt;&lt;/b&gt; is the name of the damaged workbook. If the &lt;b class="bterm"&gt;Select Sheet&lt;/b&gt; dialog box appears, select the appropriate sheet, and click &lt;b class="ui"&gt;OK&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;Select cell A1, and on the &lt;b class="ui"&gt;Edit&lt;/b&gt; menu, click &lt;b class="ui"&gt;Edit&lt;/b&gt;. Then, select an area that is approximately the same size as the range of cells that contain data in the damaged file, and then click &lt;b class="ui"&gt;Paste&lt;/b&gt; on the &lt;b class="ui"&gt;Edit&lt;/b&gt; menu.&lt;/li&gt;&lt;li&gt;With the range of cells still selected, click &lt;b class="ui"&gt;Copy&lt;/b&gt; on the &lt;b class="ui"&gt;Edit&lt;/b&gt; menu.&lt;/li&gt;&lt;li&gt;On the &lt;b class="ui"&gt;Edit&lt;/b&gt; menu, click &lt;b class="bterm"&gt;Paste Special&lt;/b&gt;, select &lt;b class="ui"&gt;Values&lt;/b&gt;, and click &lt;b class="ui"&gt;OK&lt;/b&gt;.   &lt;p&gt;This step removes the links to the damaged file and leaves only the data.&lt;/p&gt; &lt;/li&gt;&lt;/ol&gt; &lt;/span&gt;&lt;/div&gt; &lt;div class="alert"&gt; &lt;p&gt;&lt;a class="DropDown" href="javascript:ToggleDiv('divExpCollAsst_6')"&gt;&lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA790050001033" alt="Show" id="divExpCollAsst_6_img" border="0" /&gt;Open the file in Microsoft Word or WordPad&lt;/a&gt;&lt;/p&gt;  &lt;span class="ACECollapsed" border="0" id="divExpCollAsst_6"&gt; &lt;p&gt;If you have the Microsoft Excel converter installed, you might be able to open your Excel workbook in Microsoft Word. If the file does open in Word, you will not be able to recover module sheets, dialog sheets, chart sheets, macro sheets, or any embedded charts. Also, you will not recover any cell formulas, only the results of those formulas that are currently in the cells.&lt;/p&gt;  &lt;p&gt;You can also open your Excel workbook in WordPad. If the file does open, you might recover Microsoft Visual Basic code in your modules and class modules. Search for the words "Sub" or "Function" to find your code.&lt;/p&gt; &lt;/span&gt;&lt;/div&gt; &lt;div class="alert"&gt; &lt;p&gt;&lt;a class="DropDown" href="javascript:ToggleDiv('divExpCollAsst_7')"&gt;&lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA790050001033" alt="Show" id="divExpCollAsst_7_img" border="0" /&gt;Open the file in Microsoft Excel Viewer&lt;/a&gt;&lt;/p&gt;  &lt;span class="ACECollapsed" border="0" id="divExpCollAsst_7"&gt; &lt;p&gt;If you have Microsoft Excel Viewer installed, you may be able to open the Microsoft Excel workbook in Microsoft Excel Viewer, copy the cells, and paste the cells into a new workbook. However, you cannot recover module sheets, dialog sheets, chart sheets, or macro sheets. Also, you will not recover any cell formulas, only the results of those formulas that are currently in the cells.&lt;/p&gt;  &lt;p&gt;To &lt;a href="http://office.microsoft.com/search/redir.aspx?AssetID=DC011320131033&amp;amp;CTT=5&amp;amp;Origin=HA010346561033" class="OAnc"&gt;download Excel Viewer 2003&lt;/a&gt;, or for more information, see  Downloads on Microsoft Office Online.&lt;/p&gt; &lt;/span&gt;&lt;/div&gt; &lt;div class="alert"&gt; &lt;p&gt;&lt;a class="DropDown" href="javascript:ToggleDiv('divExpCollAsst_8')"&gt;&lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA790050001033" alt="Show" id="divExpCollAsst_8_img" border="0" /&gt;If a chart is linked to the corrupted file, use a macro to extract the data&lt;/a&gt;&lt;/p&gt;  &lt;span class="ACECollapsed" border="0" id="divExpCollAsst_8"&gt; &lt;ol&gt;&lt;li&gt;Enter the following macro code in a module sheet:  &lt;pre&gt; Sub GetChartValues97()&lt;br /&gt;Dim NumberOfRows As Integer&lt;br /&gt;Dim X As Object&lt;br /&gt;Counter = 2&lt;br /&gt;&lt;br /&gt;' Calculate the number of rows of data.&lt;br /&gt;NumberOfRows = UBound(ActiveChart.SeriesCollection(1).Values)&lt;br /&gt;&lt;br /&gt;Worksheets("ChartData").Cells(1, 1) = "X Values"&lt;br /&gt;&lt;br /&gt;' Write x-axis values to worksheet.&lt;br /&gt;With Worksheets("ChartData")&lt;br /&gt;.Range(.Cells(2, 1), _&lt;br /&gt;.Cells(NumberOfRows + 1, 1)) = _&lt;br /&gt;Application.Transpose(ActiveChart.SeriesCollection(1).XValues)&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;' Loop through all series in the chart and write their values to&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;' the worksheet.&lt;br /&gt;For Each X In ActiveChart.SeriesCollection&lt;br /&gt;Worksheets("ChartData").Cells(1, Counter) = X.Name&lt;br /&gt;&lt;br /&gt;With Worksheets("ChartData")&lt;br /&gt;.Range(.Cells(2, Counter), _&lt;br /&gt;.Cells(NumberOfRows + 1, Counter)) = _&lt;br /&gt;Application.Transpose(X.Values)&lt;br /&gt;End With&lt;br /&gt;&lt;br /&gt;Counter = Counter + 1&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt; &lt;/li&gt;&lt;li&gt;Insert a new worksheet into your workbook and rename it ChartData.&lt;/li&gt;&lt;li&gt;Select the chart from which you want to extract the underlying data values. &lt;p&gt;&lt;b class="cntnote"&gt; Note &lt;/b&gt;  The chart can either be embedded on a worksheet or on a separate chart sheet.&lt;/p&gt; &lt;/li&gt;&lt;li&gt;Run the GetChartValues97 macro.&lt;p&gt;The data from the chart will be placed in the ChartData worksheet.&lt;/p&gt; &lt;/li&gt;&lt;/ol&gt; &lt;/span&gt;&lt;/div&gt; &lt;h2 id=""&gt;Saving a backup copy of your file&lt;/h2&gt; &lt;p&gt;As a preventative measure, you may want to save your file often and create a backup copy every time you save. In the &lt;b class="ui"&gt;Save As&lt;/b&gt; dialog box (&lt;b class="ui"&gt;File&lt;/b&gt; menu, &lt;b class="ui"&gt;Save As&lt;/b&gt; command), click &lt;b class="ui"&gt;Tools&lt;/b&gt;, click &lt;b class="ui"&gt;General Options&lt;/b&gt;, and then select the &lt;b class="ui"&gt;Always create backup&lt;/b&gt; check box. This way, you'll have access to a good copy of the file, should the original be accidentally deleted or become corrupted.&lt;/p&gt; &lt;p&gt;You can also make sure that Excel automatically creates a recovery file at specific intervals. In the &lt;b class="ui"&gt;Options&lt;/b&gt; dialog box (&lt;b class="ui"&gt;Tools&lt;/b&gt; menu, &lt;b class="ui"&gt;Options&lt;/b&gt; command), on the &lt;b class="ui"&gt;Save&lt;/b&gt; tab, select the &lt;b class="ui"&gt;Save AutoRecover info every&lt;/b&gt; check box, and then specify a number of minutes. In the &lt;b class="ui"&gt;AutoRecover save location&lt;/b&gt; box, specify the location where you want to save the recovery file. Make sure that the &lt;b class="ui"&gt;Disable AutoRecover&lt;/b&gt; check box (under &lt;b class="ui"&gt;Workbook options&lt;/b&gt;) is not selected.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-2032415314914515202?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/2032415314914515202/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/01/repairing-corrupted-files-in-excel.html#comment-form' title='1 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/2032415314914515202'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/2032415314914515202'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/01/repairing-corrupted-files-in-excel.html' title='Repairing corrupted files in Excel'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-326775435754469619.post-965568920380260696</id><published>2009-01-12T18:29:00.000-08:00</published><updated>2009-05-15T18:30:19.594-07:00</updated><title type='text'>More ways to use HLookup and VLookup functions</title><content type='html'>&lt;p&gt;&lt;b&gt;This column provide more information about ways to use the HLOOKUP and VLOOKUP functions in Excel, along with instructions for using the Lookup Wizard, an add-in that comes with Excel. The tips include shortcuts and advice on using a mix of absolute and relative cell references to return multiple search results.&lt;/b&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;table class="collapse"&gt; &lt;tbody&gt;&lt;tr class="trbgeven"&gt; &lt;th&gt;Applies to&lt;/th&gt; &lt;/tr&gt; &lt;tr class="trbgodd"&gt; &lt;td&gt;Microsoft Office Excel 2003&lt;br /&gt;Microsoft Excel 2000 and 2002 &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;hr /&gt;&lt;a href="http://office.microsoft.com/search/redir.aspx?AssetID=FX010779791033&amp;amp;CTT=5&amp;amp;Origin=HA010565491033" class="OAnc"&gt;See all Power User columns&lt;/a&gt;&lt;br /&gt;&lt;a href="http://office.microsoft.com/search/redir.aspx?AssetID=FX010779911033&amp;amp;CTT=5&amp;amp;Origin=HA010565491033" class="OAnc"&gt;See all columns&lt;/a&gt;&lt;hr /&gt; &lt;p&gt;The last Power User column, &lt;a href="http://office.microsoft.com/search/redir.aspx?AssetID=HA010563201033&amp;amp;CTT=5&amp;amp;Origin=HA010565491033" class="OAnc"&gt;Use HLookup and VLookup to  find records in large worksheets&lt;/a&gt;, explained the basics of using the HLOOKUP and VLOOKUP functions in Microsoft Excel to find records in a large worksheet. This column explains several other ways to use those functions.&lt;/p&gt; &lt;p&gt;To refresh your memory from last time: My friend uses Microsoft Access to store and manage data about the number of hits that her Web site receives. She imports the data into Excel for analysis. She'd heard that lookup functions could save time by finding related data in the various sheets.&lt;/p&gt; &lt;p&gt;To follow the steps in this column, you need the sample worksheet from the last column, called LookupFunctions.xls. If you haven't already, &lt;a href="http://office.microsoft.com/search/redir.aspx?AssetID=HA010563201033&amp;amp;CTT=5&amp;amp;Origin=HA010565491033" class="OAnc"&gt;follow the steps in the last column&lt;/a&gt; to get ready to do the steps in this one. The sample worksheet uses fictitious Web site data that demonstrates my friend's problem. The spreadsheet contains a worksheet called Page Views (with a set of IDs that uniquely identify each site page and the hits it receives) and another called Pages (with the page IDs and the names of the pages that correspond to each ID).&lt;/p&gt; &lt;h2 id=""&gt;Let ToolTips help you write functions&lt;/h2&gt; &lt;p&gt;When you enter a formula in Excel, a ToolTip appears and lists the arguments available for that function. (If a ToolTip does not appear, select &lt;b class="ui"&gt;Options&lt;/b&gt; on the &lt;b class="ui"&gt;Tools&lt;/b&gt; menu, and on the &lt;b class="ui"&gt;General&lt;/b&gt; tab, under &lt;b class="ui"&gt;Settings&lt;/b&gt;, select the &lt;b class="ui"&gt;Function tooltips&lt;/b&gt; check box.) Those ToolTips contain hyperlinks, and you can use the links to speed up the process of selecting cell ranges and embedding the correct arguments in your formulas. Follow these steps:&lt;/p&gt; &lt;ol&gt;&lt;li&gt;In the sample worksheet, click the &lt;b class="ui"&gt;Page Views&lt;/b&gt; tab, and then clear the VLOOKUP and HLOOKUP formulas and all text in Columns E and F.&lt;/li&gt;&lt;li&gt;In Cell F4, type: &lt;p&gt;&lt;b&gt;=VLOOKUP(&lt;/b&gt;&lt;/p&gt; &lt;p&gt;When you type the opening parenthesis, a ToolTip appears.&lt;/p&gt; &lt;/li&gt;&lt;li&gt;Click &lt;b class="ui"&gt;lookup_value&lt;/b&gt; in the ToolTip, and then click Cell F3. Excel writes the value &lt;b class="ui"&gt;F3&lt;/b&gt; next to the opening parenthesis.&lt;/li&gt;&lt;li&gt;Type a comma after F3 in the formula, and then click the &lt;b class="ui"&gt;Pages&lt;/b&gt; tab.&lt;/li&gt;&lt;li&gt;In the Pages worksheet, highlight the cell range A2 to B39. The string &lt;b class="ui"&gt;Pages!A2:B39&lt;/b&gt; appears in the formula bar.&lt;/li&gt;&lt;li&gt;In the formula bar, type a comma after &lt;b class="ui"&gt;Pages!A2:B39&lt;/b&gt;. Entering a comma moves you to the next option in the ToolTip.&lt;/li&gt;&lt;li&gt;Enter the rest of the formula as shown: &lt;b class="bterm"&gt;2,false)&lt;/b&gt;, and then press ENTER. Excel returns you to the Page Views worksheet, and &lt;b class="ui"&gt;#N/A&lt;/b&gt; appears in Cell F4, indicating that you need to enter a search value in Cell F3. Typically, the #N/A error appears when your function tries to reference an empty cell. For more information about fixing #N/A errors, see &lt;a href="http://office.microsoft.com/search/redir.aspx?AssetID=HP052039361033&amp;amp;CTT=5&amp;amp;Origin=HA010565491033" class="OAnc"&gt;Correct a #N/A error&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Copy one of the page ID values from Column A to Cell F3, and then press ENTER. The corresponding page name appears in Cell F4.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;You can follow these steps whenever you get stuck on any formula: Type an equal sign, the formula name, and the opening parenthesis, and then follow the ToolTip. Remember to separate your arguments with commas.&lt;/p&gt; &lt;h2 id=""&gt;Use relative and absolute cell references to return multiple results&lt;/h2&gt; &lt;p&gt;The instance of VLOOKUP that you created in the previous section contains a reference to Cell F3. Excel calls that type of reference a &lt;i&gt;relative&lt;/i&gt; reference, meaning that if you copy the formula down or across a range of cells, Excel automatically increases the cell reference by 1 for each new instance of the formula. If any of those instances of the formula reference empty cells, Excel displays the #N/A error. &lt;/p&gt; &lt;p&gt;In contrast, absolute cell references do not change when you copy them down or across a range of cells, so using them can help you avoid #N/A errors. The following steps demonstrate how relative cell references can cause #N/A errors, and how absolute references can fix them. &lt;/p&gt; &lt;ol&gt;&lt;li&gt;On the Page Views worksheet, copy and paste or type this formula into Cell D4:&lt;p&gt;&lt;b&gt;=VLOOKUP(A4,Pages!A2:B39,2,false)&lt;/b&gt;&lt;/p&gt; &lt;/li&gt;&lt;li&gt;Click Cell D4, rest your mouse pointer on the lower-right corner of the cell until it changes to a black plus sign (+), and then drag the mouse pointer down to Cell D41. The page names that correspond to each ID appear in Column D.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;At this point, &lt;b class="ui"&gt;#N/A&lt;/b&gt; appears in several cells. What happened? If you click cells in Column D, you see that Excel also increased the cell references by one after the word &lt;b class="bterm"&gt;Pages!&lt;/b&gt; in the formula. (In case you haven't &lt;a href="http://office.microsoft.com/search/redir.aspx?AssetID=HA010563201033&amp;amp;CTT=5&amp;amp;Origin=HA010565491033" class="OAnc"&gt;read the previous article&lt;/a&gt;, "Pages!A2:B39" is called the &lt;b class="ui"&gt;table array argument&lt;/b&gt;. For more information about the argument, &lt;a href="http://office.microsoft.com/search/redir.aspx?AssetID=HA010563201033&amp;amp;CTT=5&amp;amp;Origin=HA010565491033" class="OAnc"&gt;read the previous article&lt;/a&gt;.) In other words, the formula in Cell D4 references Cells A2 through B39 on the Pages worksheet, which is what you want. But look at the formula associated with Cell D5: It references Cells A3 through B40. If you go back to the Pages worksheet, you'll see that Cell B40 is empty. Excel returns the #N/A message because some instances of the formula contain references to empty cells.&lt;/p&gt; &lt;p&gt;To work around the problem, use &lt;b class="ui"&gt;absolute&lt;/b&gt; cell references. Absolute references prevent Excel from changing cell references in a formula when you copy that formula. Follow these steps:&lt;/p&gt; &lt;ol&gt;&lt;li&gt;In the Page Views worksheet, clear Cells D5 through D41.&lt;/li&gt;&lt;li&gt;In Cell D4 (or the formula bar, if that's easier), add dollar signs to the formula as shown: &lt;p&gt;&lt;b&gt;=VLOOKUP(A4,Pages!$A$2:$B$39,2,FALSE)&lt;/b&gt;&lt;/p&gt; &lt;p&gt;The dollar signs make the cell references absolute.&lt;/p&gt; &lt;/li&gt;&lt;li&gt;Point to the lower-right corner of Cell D4 until your mouse pointer changes to a black plus sign, and then drag the pointer down to Cell D41. As you copy the formula, the dollar signs prevent Excel from changing any cell references in the table array argument. This time, the page names that correspond to each ID appear in Column D with no errors.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;The formula in Step 2 uses absolute columns and rows (the dollar signs are a dead giveaway). You can use a mix of relative columns and absolute rows, or vice versa. For example:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;If you need a relative column reference and an absolute row reference, use &lt;b class="ui"&gt;A$2&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;If you need an absolute column reference and a relative row reference, use &lt;b class="ui"&gt;$A2&lt;/b&gt;.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;You can mix absolute and relative references as needed. For example, you could use $A2:B$39, or any other combination of characters. Just make sure that you place the dollar sign before the column or row that you want to designate as an absolute reference. The function fails otherwise.&lt;/p&gt; &lt;p&gt;Finally, for more information about formula error messages, see &lt;a href="http://office.microsoft.com/search/redir.aspx?AssetID=HP052039361033&amp;amp;CTT=5&amp;amp;Origin=HA010565491033" class="OAnc"&gt;Correct a #N/A error&lt;/a&gt;, &lt;a href="http://office.microsoft.com/search/redir.aspx?AssetID=HP052039481033&amp;amp;CTT=5&amp;amp;Origin=HA010565491033" class="OAnc"&gt;Correct a #REF! error&lt;/a&gt;, and &lt;a href="http://office.microsoft.com/search/redir.aspx?AssetID=HP052039501033&amp;amp;CTT=5&amp;amp;Origin=HA010565491033" class="OAnc"&gt;Correct a #VALUE! error&lt;/a&gt;.&lt;/p&gt; &lt;h2 id=""&gt;Use formula auditing to find empty cells and fix broken functions&lt;/h2&gt; &lt;p&gt;Typically, a function doesn't work because it references at least one empty cell. You can use the formula auditing tools in Excel to find the empty cell and fix the broken function. The formula auditing tools use arrows and icons to point to the cells from which a function tries to take the data it needs.&lt;/p&gt; &lt;p&gt;&lt;b class="cntnote"&gt; Important &lt;/b&gt;     To follow the steps in this section, you must first enable an error checking option. On the &lt;b class="ui"&gt;Tools&lt;/b&gt; menu, click &lt;b class="ui"&gt;Options&lt;/b&gt;, click the &lt;b class="ui"&gt;Error Checking&lt;/b&gt; tab, and then select the &lt;b class="ui"&gt;Formulas referring to empty cells&lt;/b&gt; check box.&lt;/p&gt; &lt;p&gt;To see the auditing tools in action:&lt;/p&gt; &lt;ol&gt;&lt;li&gt;On the Page Views worksheet, remove the dollar signs from the formula in cell D4.&lt;/li&gt;&lt;li&gt;Clear cells D5 through D41, and then copy the changed formula down to Cell D41. Because all instances of the formula except the first one contain an error, Excel displays a green triangle in the upper-left corner of each cell: &lt;p&gt;&lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA010580771033" alt="A cell with a formula error" border="0" /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li&gt;Select Cell D5. The &lt;b class="ui"&gt;Trace Error&lt;/b&gt; icon &lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA010575101033" alt="The Trace Error icon" border="0" /&gt; appears.&lt;/li&gt;&lt;li&gt;Click the arrow to the right of the icon, and then click &lt;b class="ui"&gt;Trace Empty Cell&lt;/b&gt;. The following arrow and icon appear, indicating that the empty cell resides on another worksheet.  &lt;p&gt;&lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA010580831033" alt="Excel indicating that the empty cell resides on another worksheet" border="0" /&gt;&lt;/p&gt; &lt;/li&gt;&lt;li&gt;Double-click the black arrow that leads from the icon to the cell.&lt;/li&gt;&lt;li&gt;Double-click the entry in the &lt;b class="ui"&gt;Go to&lt;/b&gt; dialog box. Excel opens the Pages worksheet because that worksheet contains the empty cell.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;At this point, you need to notice something subtle: In the Pages worksheet, Excel highlights the cell range A3 to B40, even though the data only resides in cells A2 to B39. The highlight is showing you that the formula is searching the wrong range of cells. Hence, the error.&lt;/p&gt; &lt;p&gt;To see a more pronounced example of this behavior, go back to the Page Views worksheet, select Cell D10, and repeat Steps 4 through 6. The highlight in the Pages worksheet extends even further down to indicate the greater number of empty cells referenced by the instance of the formula in Cell D10.&lt;/p&gt; &lt;p&gt;&lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA010580761033" alt="The highlight extending to show empty cells" border="0" /&gt;&lt;/p&gt; &lt;h2 id=""&gt;Use the Lookup Wizard to save time&lt;/h2&gt; &lt;p&gt;If you don't have the time to write a function or if writing functions still frustrates you, you can use the Lookup Wizard. The Lookup Wizard comes with Excel, so you don't need to download it (but Excel may prompt you to install it the first time you try to use it). The wizard uses the INDEX and MATCH functions (instead of VLOOKUP and HLOOKUP) to return records.&lt;/p&gt; &lt;p&gt;Unlike the lookup functions, the INDEX function requires you to specify row and column labels. The INDEX function also returns values from unsorted lists.&lt;/p&gt; &lt;p&gt;The MATCH function determines the row that contains the desired value. You can use INDEX and MATCH to enter more than one search term and return the value that corresponds to the intersection of the two terms. For example, the following table contains shipping data for the first three months of 1994, 1995, and 1996.&lt;/p&gt; &lt;table class="collapse"&gt; &lt;tbody&gt;&lt;tr class="trbgeven"&gt; &lt;th&gt;Units Shipped&lt;/th&gt; &lt;/tr&gt;  &lt;tr class="trbgodd"&gt; &lt;td&gt;&lt;br /&gt;&lt;/td&gt; &lt;td&gt;January&lt;/td&gt; &lt;td&gt;February&lt;/td&gt; &lt;td&gt;March&lt;/td&gt; &lt;/tr&gt;  &lt;tr class="trbgeven"&gt; &lt;td&gt;1994&lt;/td&gt; &lt;td&gt;37&lt;/td&gt; &lt;td&gt;43&lt;/td&gt; &lt;td&gt;61&lt;/td&gt; &lt;/tr&gt;  &lt;tr class="trbgodd"&gt; &lt;td&gt;1995&lt;/td&gt; &lt;td&gt;40&lt;/td&gt; &lt;td&gt;60&lt;/td&gt; &lt;td&gt;52&lt;/td&gt; &lt;/tr&gt;  &lt;tr class="trbgeven"&gt; &lt;td&gt;1996&lt;/td&gt; &lt;td&gt;31&lt;/td&gt; &lt;td&gt;50&lt;/td&gt; &lt;td&gt;64&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;Using INDEX and MATCH, you can specify multiple search terms such as "1995" and "March." In that case, the functions would return &lt;b class="ui"&gt;52&lt;/b&gt;, the value at the intersection of those terms.&lt;/p&gt; &lt;p&gt;The steps in this section explain how to configure Excel to run the Lookup Wizard, and how to use the wizard.&lt;/p&gt; &lt;p&gt;First, let's configure Excel.&lt;/p&gt; &lt;ol&gt;&lt;li&gt;On the &lt;b class="ui"&gt;Tools&lt;/b&gt; menu, click &lt;b class="ui"&gt;Add-Ins&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;In the &lt;b class="ui"&gt;Add-Ins&lt;/b&gt; dialog box, click &lt;b class="ui"&gt;Lookup Wizard&lt;/b&gt;, and then click &lt;b class="ui"&gt;OK&lt;/b&gt;.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Now let's run the add-in. These steps explain how to duplicate the results you created earlier using the VLOOKUP function. We'll use values from the Page Views and Pages worksheets, and return a result to a blank cell on the Page Views worksheet.&lt;/p&gt; &lt;ol&gt;&lt;li&gt;Open the sample spreadsheet (LookupFunctions.xls) and select the Pages worksheet.&lt;/li&gt;&lt;li&gt;On the &lt;b class="ui"&gt;Tools&lt;/b&gt; menu, click &lt;b class="ui"&gt;Lookup&lt;/b&gt;. You should see the following text and cell range in the wizard.&lt;p&gt;&lt;img src="http://office.microsoft.com/global/images/default.aspx?AssetID=ZA010580801033" alt="The cell range in the Lookup Wizard" border="0" /&gt;&lt;/p&gt; &lt;p&gt;If the text seems a bit cryptic, remember that you're defining the location and range of cells through which the function searches. When you see those values, click &lt;b class="ui"&gt;Next&lt;/b&gt;.&lt;/p&gt; &lt;/li&gt;&lt;li&gt;Ensure that &lt;b class="ui"&gt;Page Name&lt;/b&gt; appears in the top drop-down box, and then pick a page ID number from the bottom drop-down box and click &lt;b class="ui"&gt;Next&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;Do one of the following:   &lt;ul&gt;&lt;li&gt;If you want your worksheet to display only the result of your search, click &lt;b class="ui"&gt;Copy just the formula to a single cell&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;If you want the worksheet to display the search result and the parameters used in the search, click &lt;b class="ui"&gt;Copy the formula and lookup parameters&lt;/b&gt;, and then click &lt;b class="ui"&gt;Next&lt;/b&gt;. &lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;li&gt;Do one of the following:   &lt;ul&gt;&lt;li&gt;If you chose to display only the search result, enter a reference to a blank cell in the box, and then click &lt;b class="ui"&gt;Finish&lt;/b&gt;.&lt;/li&gt;&lt;li&gt;If you chose to display the result and the lookup parameters, enter references to three blank cells, and then click &lt;b class="ui"&gt;Finish&lt;/b&gt;.&lt;/li&gt;&lt;/ul&gt; &lt;/li&gt;&lt;/ol&gt;&lt;p&gt;The wizard performs the lookup and writes the result or results to the cell or cells you referenced in Step 6.&lt;/p&gt; &lt;h2 id=""&gt;A final reminder&lt;/h2&gt; &lt;p&gt;As you use lookup functions, remember that you're pointing to a data string in one location, telling Excel to find either a partial or absolute match for that data string in another location, and then telling Excel to display a third value that lies either next to or near that second value.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/326775435754469619-965568920380260696?l=myexcell.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://myexcell.blogspot.com/feeds/965568920380260696/comments/default' title='Poskan Komentar'/><link rel='replies' type='text/html' href='http://myexcell.blogspot.com/2009/01/more-ways-to-use-hlookup-and-vlookup.html#comment-form' title='0 Komentar'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/965568920380260696'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/326775435754469619/posts/default/965568920380260696'/><link rel='alternate' type='text/html' href='http://myexcell.blogspot.com/2009/01/more-ways-to-use-hlookup-and-vlookup.html' title='More ways to use HLookup and VLookup functions'/><author><name>Aisyah Runi</name><uri>http://www.blogger.com/profile/09754809777891988684</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='21' height='32' src='http://bp3.blogger.com/_iNFxbPL4FYE/R_dMDxJPHQI/AAAAAAAAAAM/L8A99OeHoPU/S220/runi001.jpg'/></author><thr:total>0</thr:total></entry></feed>
