<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SmittyPro</title>
	<atom:link href="http://www.smittypro.com/Blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.smittypro.com/Blog</link>
	<description>Witticisms, Help, Tutorials and More</description>
	<lastBuildDate>Mon, 09 Jul 2012 23:36:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Creating Effective Forms with Excel &#8211; The Worksheet Form (Part 2 of 3)</title>
		<link>http://www.smittypro.com/Blog/?p=476</link>
		<comments>http://www.smittypro.com/Blog/?p=476#comments</comments>
		<pubDate>Mon, 09 Jul 2012 22:10:37 +0000</pubDate>
		<dc:creator>"Smitty"</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.smittypro.com/Blog/?p=476</guid>
		<description><![CDATA[Note: this article was written specifically for Excel 2010 and its Ribbon interface, however the concepts reviewed will apply for the most part to earlier versions. In our last article we discussed how Excel is a fantastic tool for creating forms, and reviewed the native Data Form, which is built into Excel (but you need [...]]]></description>
			<content:encoded><![CDATA[<div class="al2fb_like_button"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like ref="AL2FB" layout="box_count" show_faces="true" width="450" action="like" colorscheme="light" href="http://www.smittypro.com/Blog/?p=476"></fb:like></div><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/home/?status=Creating+Effective+Forms+with+Excel+%E2%80%93+The+Worksheet+Form+%28Part+2+of+3%29+http%3A%2F%2Fis.gd%2FrnazWF" title="Post to Twitter"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.smittypro.com/Blog/?p=476&amp;t=Creating+Effective+Forms+with+Excel+%E2%80%93+The+Worksheet+Form+%28Part+2+of+3%29" title="Post to Facebook"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.google.com/buzz/post?url=http://www.smittypro.com/Blog/?p=476&amp;imageurl=" title="Post to Google Buzz"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/gbuzz/tt-gbuzz-micro3.png" alt="Post to Google Buzz" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.smittypro.com/Blog/?p=476&amp;title=Creating+Effective+Forms+with+Excel+%E2%80%93+The+Worksheet+Form+%28Part+2+of+3%29&amp;summary=%0D%0A+Note%3A+this+article+was+written+specifically+for+Excel+2010+and+its+Ribbon+interface%2C+however+the+concepts+reviewed+will+apply+for+the+most+part+...&amp;source=SmittyPro" title="Post to LinkedIn"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin-micro3.png" alt="Post to LinkedIn" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://technorati.com/faves?add=http://www.smittypro.com/Blog/?p=476" title="Post to Technorati"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati-micro3.png" alt="Post to Technorati" /></a></p></div><div>
<div style="padding-left: 30px;"><span style="font-family: Times New Roman; font-size: small;"> </span><em><span style="color: #4f81bd;"><span style="font-family: Calibri;">Note: this article was written specifically for Excel 2010 and its Ribbon interface, however the concepts reviewed will apply for the most part to earlier versions.</span></span></em></div>
</div>
<div>
<div><span style="font-family: Calibri;">In our last article we discussed how Excel is a fantastic tool for creating forms, and reviewed the native Data Form, which is built into Excel (but you need to work to find it in Excel 2007+).  It’s a simple tool for entering transactional data, like check register or vehicle service information, but isn’t a great tool for one-off purpose-built forms that generally only need to capture your information one time, like an application form, employee expense report or time-off request.  The next form type we’ll discuss is the worksheet form, in which you model a worksheet to mimic what you would see with a printed form.  In fact, many companies make forms like this in Excel so they can replace pre-printed forms, and it saves quite a bit of expense, both from not having to send something to a commercial printer, as well as being able to capture data electronically (although tragically, most companies that employ digital forms – in Excel or specific form building software applications &#8211; never do anything more with that digital information).  Another key point about this article is that we’ll be talking about how to design an intelligent user-entry form for one-time use, not being able to actually capture the data in a transactional sense, like keeping a record of invoices you generate.  That is easy enough to do, but it requires VBA (Visual Basic for Applications) code, which is outside of the scope of this article.  However, there will be a link to a Company Invoice template form that can capture transactional data that you’re free to modify for your own use.</span></div>
</div>
<div>
<div><span style="font-family: Calibri;">As mentioned in the last article, the key to intelligent form design is making it as easy as possible for your users to give you the information that you want.  If you make it hard for them to give it to you, they will make it hard for you to get it out.  It’s really as simple as that.  This isn’t necessarily by any conscious decision on their part, it’s just a fact that if you make it difficult for someone to give you information, they generally won’t be inclined to spend a whole lot of time error checking their entries.  We’ve all had negative experiences filling out one form or another, so that leads to two primary principles in design: first, make it easy and intuitive for people to enter information (data), and second, structure your form in such a way that it flows from point to point in a natural progression.  Here’s a simple example for entering phone numbers: most people will enter “(212) 555-1212”, and waste time with the parentheses and hyphen, when Excel has a Telephone number format that will accept “2125551212” and automatically format it as “(212) 555-1212”.  Do you have to educate your users to a certain extent, sure, but they’ll thank you once you do, and that can cascade down to how they interact with other intelligently designed forms &amp; applications in the future.  In fact, intelligent design extends far beyond just filling out forms, but how people interact with applications in the first place.</span></div>
</div>
<div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span><span style="font-family: Calibri;">With that in mind we’ll be covering various elements native in Excel to be able to facilitate efficient design and user input:</span></div>
</div>
<ul>
<li><em><span style="color: #4f81bd; font-family: Cambria;">Worksheet Protection</span></em><span style="font-family: Calibri;"> – Using some of Excel’s internal functionality to direct data entry, and prevent them from overwriting important formulas or other information.</span></li>
<li><em><span style="color: #4f81bd; font-family: Cambria;">Data Validation</span></em><span style="font-family: Calibri;"> (to limit or direct user entry) – For instance in a Time-Off request you wouldn’t want to let a user enter a date before today.  Or using lists to limit what a user can select, like all of the US states, instead of giving them the opportunity to misspell Mississippi (or in one case I saw not too long ago: “Missasagua”, and that’s probably misspelled).</span></li>
<li><em><span style="color: #4f81bd; font-family: Cambria;">Conditional Formatting</span></em><span style="font-family: Calibri;"> – You can use this to indicate to a user that a cell needs to have an entry.</span></li>
<li><em><span style="color: #4f81bd; font-family: Cambria;">Cell Formatting</span></em><span style="font-family: Calibri;"> – Just like the telephone number formatting example.</span></li>
<li><em><span style="color: #4f81bd; font-family: Cambria;">Worksheet Formulas</span></em><span style="font-family: Calibri;"> (to prefill entries based on a Data Validation selection) – Let’s say you have a customer list in a worksheet, you can use VLOOKUP to pre-fill the customer address information as soon as the user selects Customer Name from a Data Validation list.</span></li>
<li><em><span style="color: #4f81bd; font-family: Cambria;">Worksheet Controls</span></em><span style="font-family: Calibri;"> – Check Boxes, Option Buttons, and other web-type features that make it easier for your users to fill out a form faster.  An example would be a “Tax Required” button on an Invoice form that could then be used to calculate the appropriate tax.</span></li>
</ul>
<div>
<div><span style="font-family: Calibri;">None of the methods we’ll be discussing are infallible, the data/input that you receive is only as good as the users giving it, and there will always be mistakes.  But if you can limit that on the front end, then you greatly simplify both your life and theirs, and you can all subsequently spend more time on more important things.</span></div>
<div><em><span style="color: #4f81bd; font-family: Cambria;">Worksheet Protection </span></em><span style="font-family: Calibri;">– What is that anyway?  Well, by default all cells in an Excel worksheet (over 1 billion now) are protected.  Which means that if you protect a worksheet, then user entry into any cell is restricted.  But you can use that to your advantage, so let’s say that you want to allow a user to enter information into certain cells, but not alter others, then you simply unlock those cells and protect the worksheet.  Once you do that users can only enter information into those unprotected cells. </span></div>
</div>
<div>
<div style="padding-left: 30px;"><span style="color: #3366ff;"><em><span style="font-family: Calibri;">NOTE: you can select multiple, non-contiguous cells with CTRL+Left-Click, then CTRL+1 launch the Format Cells dialog.  From there goto the Protection tab and uncheck the “Locked” check box.  When you protect the worksheet afterwards, then just those cells will be open for entry.  The Hidden option is for formulas; when you select that then users will only see the results of formulas, as opposed to the actual formulas themselves.  This can be very handy if you have novice users who might get confused when they see formulas (or if you have a very complex formula that you don’t want to share).</span></em></span></div>
</div>
<div><span style="font-family: Calibri;"> </span></div>
<div id="attachment_482" class="wp-caption aligncenter" style="width: 534px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/Protection.jpg"><img class="size-full wp-image-482" title="Protection" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/Protection.jpg" alt="" width="524" height="268" /></a><p class="wp-caption-text">Unlocking Cells</p></div>
<div>
<div><span style="font-family: Calibri;">An added bonus to Worksheet Protection is that it introduces a natural Tab order (meaning that your users can use the Tab key to move from each unprotected cell to the next).  A key note here with regards to design is that the natural Tab order goes from Left-to-Right, then back down to the next row and does not deviate, so you need to keep that in mind with your “intelligent” design.  By way of example, think of any Internet form you’ve filled out where you tabbed to different fields in the wrong order, requiring you to redirect to go back to the right place.  What’s that do?  Wastes time right?  While it might not seem consequential, think of a company like Verizon with 200,000 employees.  If they have a poorly designed form that even only 20% of the staff use, and they spend an extra x minutes per week/month working with an inefficiently designed process then you can only imagine the cascading effect that can have on their internal efficiency, and subsequently why our rates go up each year.  Another thing that taking advantage of the natural Tab order does is keep your user’s fingers on the keyboard instead of transitioning to the mouse to move from cell to cell.  Anytime you can eliminate wasted motion like that is a good thing and again, it might seem inconsequential, but it adds up over time.  And time goes two ways, you waste it or save it, but you can’t get it back.</span></div>
</div>
<div>
<div><span style="font-family: Calibri;">Once you’ve selected the cells you want users to be able to enter data into you can goto the Review Tab and select Protect Sheet.  Or in the vein of efficiency, use the keyboard shortcut ALT+T+P+P, both of which will display the Protection dialog:</span></div>
</div>
<div><span style="font-family: Calibri;"> </span></div>
<div class="mceTemp mceIEcenter">
<div id="attachment_484" class="wp-caption aligncenter" style="width: 296px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/ProtectSheet.jpg"><img class="size-full wp-image-484" title="ProtectSheet" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/ProtectSheet.jpg" alt="" width="286" height="329" /></a><p class="wp-caption-text">Worksheet Protection Options</p></div>
</div>
<div>
<div><span style="font-family: Calibri;">Beginning with Excel 2003 Microsoft added significantly more protection options, some of which you might find helpful beyond just locking/unlocking cells.  Deciding which options to allow is entirely up to you, and it may well very change from form to form, so it’s well worth experimenting with the options to see how they all work.</span></div>
<div><span style="font-family: Calibri;">Standard worksheet protection with unlocked cells should suffice for most forms, but it does take some thought when you plan the form to ensure that you can follow the Tab Order directionality.  There are other ways to allow tabbed behavior using Defined Name Ranges and/or VBA (Visual Basic for Applications) code, but that’s another discussion.  You’ll find more details on worksheet protection in this article: <a title="Link to Excel – Automating Data Entry and Protecting your Data" href="http://www.smittypro.com/Blog/?p=79"><span style="color: #0000ff;">Automating Data Entry and Protecting your Data</span></a>.</span></div>
</div>
<div>
<div><em><span style="color: #4f81bd; font-family: Cambria;">Data Validation</span></em><span style="font-family: Calibri;"> – This is one of the most powerful tools you have when it comes to building powerful, user-friendly and intelligently designed forms.  Data Validation allows you to direct a user to only input specific information, like select from a list of States, input a certain range of numbers, or dates.  For example, if you have an Employee Time-Off request, you wouldn’t want someone to be able to enter a day before today.  Or you might have an Annual Employee Performance Appraisal and want to limit a recommended annual merit increase to a certain percentage.  For more information on how to set up Data Validation, see our previous article here:  <a title="Link to Automating Data Entry with Data Validation Lists" href="http://www.smittypro.com/Blog/?p=25"><span style="color: #0000ff;">Automating Data Entry with Data Validation Lists</span></a>.</span></div>
<div><span style="font-family: Calibri;">The example workbook for this article is a very simple customer information form.  Here is an example of using Data Validation to allow a user to select from a list of Titles:</span></div>
</div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div id="attachment_490" class="wp-caption aligncenter" style="width: 300px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/DataVal4.jpg"><img class="size-full wp-image-490" title="DataVal" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/DataVal4.jpg" alt="" width="290" height="296" /></a><p class="wp-caption-text">Data Validation List</p></div>
<div><span style="font-family: Calibri;"> </span></div>
<div>
<div><span style="font-family: Calibri;">Notice how the cells requiring are shaded orange, but the Data Validation cell where “Mr.” has been selected is white?  That brings us to our next topic, which is Conditional Formatting. </span></div>
</div>
<div>
<div style="padding-left: 30px;"><span style="font-family: Times New Roman; font-size: small;"> </span><span style="font-family: Calibri;"><em>Note: Excel internally recognizes Data Validation input on a worksheet, and it’s captured with the VBA Worksheet_Change event, which can be a very powerful tool for directing workflow based on a user’s selection.</em></span></div>
</div>
<div>
<div><em><span style="color: #4f81bd; font-family: Cambria;">Conditional Formatting </span></em><span style="font-family: Calibri;">- Once you’ve set up your form, and for this article we’re using a very simple example, you can use Conditional Formatting to focus the user’s attention on where they need to enter data.  This won’t stop someone from submitting your form with incomplete information (you can do that with VBA), but it serves as a visual clue that they need to fill in certain fields.  To employ Conditional Formatting, simply select the cells that you want shaded (HINT: this can be combined with the steps to unlock cells, as you have already selected the cells, so why repeat it?), goto the Home tab and select Conditional Formatting, or use the keyboard shortcut ALT+O+D.  In this case we applied a very simple condition that simply checks to see if each cell has a value of nothing (“”) or not.  If the condition is true, then Excel applies the format, otherwise it won’t.  There are a lot of features available in Conditional Formatting, far too many to review here, so please spend some time getting used to it.  Beginning in Excel 2007 Microsoft greatly enhanced your capabilities with this tool, so it’s well worth getting to know.  For instance, you were previously limited to 3 conditions, now you have 64.  Although please think conservatively, as actually having that many conditions could cause just as much confusion as not.</span></div>
</div>
<div style="padding-left: 30px;"><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div id="attachment_491" class="wp-caption aligncenter" style="width: 653px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/CondFormat.jpg"><img class="size-full wp-image-491" title="CondFormat" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/CondFormat.jpg" alt="" width="643" height="288" /></a><p class="wp-caption-text">Conditional Formatting</p></div>
<div>
<div><em><span style="color: #4f81bd;"><span style="font-family: Calibri;"> </span></span></em></div>
<div style="padding-left: 30px;"><em><span style="color: #4f81bd;"><span style="font-family: Calibri;">Note on Quotes: when you initially enter =”” in the Conditional Formatting Rule criteria and confirm it with OK/Apply you probably won’t see anything happen, which might lead you to believe that you did something wrong.  You didn’t, but Excel will initially change the formula to =””””””, so first hit Apply, then go in and Edit the rule and remove the additional quotes that Excel added. Unfortunately, this is by design as Excel has a hard time with quotes (and apostrophes), as they have internal functions as well as what you’re trying to do with them.</span></span></em></div>
</div>
<div>
<div><em><span style="color: #4f81bd; font-family: Cambria;">Cell Formatting</span></em><span style="font-family: Calibri;"> – The next element of form design is using custom cell formats to your advantage.  It’s all too common to see users fill out forms using literal formats, like entering “(212) 555-1212”, which is unnecessary, as you can tell Excel to do it for you.  For forms especially, there’s even a series of “Special” options that have been pre-built for you.  In this case we’ll select Phone Number.  Now all your users need to do is enter “2125551212” and Excel will automatically format it for you.  Cell formatting also preserves the integrity of a value, whereas user entered punctuation can render it nearly useless as Excel will then read it as text.  It is possible to get to the value with the use of some formulas, but why go to that extent if you can avoid it up front?  The key is to use Excel’s tools so that it works for you, as opposed to you working for Excel (which happens a lot).  Fortunately, Excel’s pretty smart, so it knows a lot of things, like “$123.45” is a number even though the $ has been added by hand, but you should never count on it, just like you shouldn’t anticipate that users won&#8217;t make mistakes (especially since we all do).</span></div>
</div>
<div><em><span style="color: #4f81bd; font-family: Cambria;"> </span></em></div>
<div><em> </em></div>
<div><em> </em></div>
<div><em> </em></div>
<div><em> </em></div>
<p><em></p>
<div id="attachment_492" class="wp-caption aligncenter" style="width: 534px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/SpecialFormat.jpg"><img class="size-full wp-image-492" title="SpecialFormat" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/SpecialFormat.jpg" alt="" width="524" height="471" /></a><p class="wp-caption-text">Format Cells - Phone Number</p></div>
<p></em></p>
<div>
<div><em><span style="color: #4f81bd; font-family: Cambria;">Worksheet Formulas</span></em><span style="font-family: Calibri;"> – You can use formulas to your advantage in Excel forms, and it is one of its most powerful features.  While we’re not going to get into a full-blown formula discussion here, as there have been entire books devoted to the subject, we’ll cover a few concepts to give you an idea of what can be done, which is primarily having Excel perform calculations so your users don’t have to do it themselves (can you say error management?).  Let’s go back to the Employee Performance Appraisal example.  Imagine that you have a list of all employees on another worksheet (Employee ID, Name, Hire Date, Hourly Salary, etc.), you can use formulas to populate all of that information simply by selecting the Employee ID from a Data Validation list.  Here’s an article on <a title="Link to Excel – IF statements &amp; LOOKUPS" href="http://www.smittypro.com/Blog/?p=224"><span style="color: #0000ff;">IF statements &amp; LOOKUPS</span></a>, <span style="font-size: small;">which allow you to do that.</span> You can also use a method called Concatenation to combine information from certain cells and create unique text strings.  For instance, let’s say that your employee e-mail naming convention is “LastName.FirstName@Company.com”, and you have First Name in cell A1 and Last Name in cell B1.  You can use:</span></div>
</div>
<div style="padding-left: 30px;"><span style="font-family: Times New Roman; font-size: small;"> </span><span style="color: #4f81bd;"><span style="font-family: Calibri;"><a href="mailto:=B1&amp;”.”&amp;”A1”&amp;”@CompanyName.com">=B1&amp;”.”&amp;”A1”&amp;”@CompanyName.com</a>” </span></span></div>
<div><span style="font-family: Calibri;">Which would create “Jones.Bob@XYZco.com”.  The key here is the Ampersand (&amp;) operator, which lets you link both cell references and values.  Since that formula creates a text string you can coerce it to be a hyperlink by using the following:</span></div>
<div style="padding-left: 30px;"><span style="font-family: Times New Roman; font-size: small;"> </span><span style="color: #4f81bd;"><span style="font-family: Calibri;">=HYPERLINK(<a href="mailto:B1&amp;”.”&amp;”A1”&amp;”@CompanyName.com">B1&amp;”.”&amp;”A1”&amp;”@CompanyName.com</a>”)</span></span></div>
<div>
<div><span style="font-family: Calibri;">This brings up an interesting point that if you try to do this with numeric references you’ll lose any number formatting you might have applied as Excel now sees that data as text, but you can use the TEXT function to coerce it back within your new text string.  The following example lets you concatenate text and today’s date all within one cell:</span></div>
<div style="padding-left: 30px;"><span style="font-family: Times New Roman; font-size: small;"> </span><span style="color: #4f81bd;"><span style="font-family: Calibri;">=”Report Printed on: ”&amp;TEXT(TODAY(),”mm/dd/yyyy”)</span></span></div>
</div>
<div>
<div><span style="font-family: Calibri;">Which would read: “Report Printed on: 07/09/2012”.  Otherwise you’d see: “Report Printed on: 41099” (41099 is Excel’s way of storing the date value).  Pretty slick, huh?  I liken this to Excel knows that I’m on Windows 7, it knows my system’s regional preferences, but it doesn’t know my intention with the value I’m referencing, even if I’ve already formatted the a referenced cell properly, so it runs home and converts the value into its basest element, in this case the system date value.</span></div>
</div>
<div>
<div><em><span style="color: #4f81bd; font-family: Cambria;">Worksheet Controls </span></em><span style="font-family: Calibri;">- The final element to worksheet forms is using worksheet controls, of which there are two distinct categories: Form Controls &amp; ActiveX Controls.  These are items like Check Boxes, Option Buttons, List &amp; ComboBox controls, etc., all of which can be used to simplify form use.  For example, you could add a Check Box to a form for “Tax Required?”.  Once checked it would trigger a formula that will calculate the Tax due on a purchase order.  For the purpose of this article, we’re only going to discuss Form Controls, as they can be formatted and controlled within Excel itself.  ActiveX controls on the other hand are VBA components and you generally need to write code against them in order to expose their full capabilities.  While they are more flexible and robust than their Form control counterparts, they are more difficult to master.</span></div>
</div>
<div>
<div><span style="font-family: Calibri;">The first thing you need to do is expose the Controls themselves, which are located on the Developer tab in the Ribbon.  As this also exposes VBA elements, Microsoft chose to hide this Ribbon element by default, since unfortunately most Excel users will never use it.  In Excel 2010 goto File</span>à<span style="font-family: Calibri;">Options</span>à<span style="font-family: Calibri;">Customize Ribbon and check the “Developer” check box in the right-hand pane.  In Excel 2007 this is a check box under the General options.</span></div>
<div><span style="font-family: Calibri;"> </span></div>
</div>
<div id="attachment_493" class="wp-caption aligncenter" style="width: 874px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/ShowtheDevTab.jpg"><img class="size-full wp-image-493" title="ShowtheDevTab" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/ShowtheDevTab.jpg" alt="" width="864" height="700" /></a><p class="wp-caption-text">Show the Developer Tab on the Ribbon</p></div>
<div>
<div><span style="font-family: Calibri;">Once you confirm this you’ll now see the Developer tab appear on the right side of the Ribbon.  From there you’ll see a Ribbon group called Controls, and clicking on the Insert button will display the controls that you have available:</span></div>
</div>
<div>
<div><span style="font-family: Calibri;">Like Conditional Formatting and Formulas, there are so many options here, that we’re just going to briefly touch on the topic with a general example.  But you should experiment with as many of the controls as you can.  Once you do you’ll probably find yourself using them all the time, even for your own work.  One of the most common controls to use is the Button.  Buttons are great because you can assign macros to them to perform certain tasks, like print a form once it’s been filled out.  What’s really cool is that you can assign a macro to almost any object.  Form Controls are objects, but so are any of the shapes you’ll find from the Insert</span>à<span style="font-family: Calibri;">Shapes Ribbon group.  I prefer to use shapes to assign macros to since they’re much more visually appealing, and while it may seem inconsequential, people will actually fill out a well-designed and appealing form much faster and with less errors than one that‘s poorly designed..  Which would you rather see:</span></div>
</div>
<div><span style="font-family: Calibri;"> </span></div>
<div id="attachment_494" class="wp-caption aligncenter" style="width: 240px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/Buttons.jpg"><img class="size-full wp-image-494" title="Buttons" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/Buttons.jpg" alt="" width="230" height="197" /></a><p class="wp-caption-text">Form Button vs. a nice Shape Button</p></div>
<div>
<div><span style="font-family: Calibri;">Building a good form not only takes functionality into consideration, but needs to appeal to the end user as well.  Just think about how much easier your tax forms would be to fill out if they were thoughtfully designed.</span></div>
</div>
<div>
<div style="padding-left: 30px;"><span style="font-family: Times New Roman; font-size: small;"> </span><span style="font-family: Calibri;"><span style="color: #4f81bd;"><em>Note: in the example workbook both buttons have a macro assigned to them to display the worksheet form in Print Preview mode, so you’ll need to enable Macros in order for them to work.  You’ll find an Introduction to Macros article here: </em><a title="Link to Excel – Automating Tasks with the Macro Recorder – First Steps" href="http://www.smittypro.com/Blog/?p=101">Automating Tasks with the Macro Recorder – First Steps</a></span>.</span></div>
</div>
<div>
<div><span style="font-family: Calibri;">For our working example we’ll add a Check Box to our form to indicate whether our contact wants to receive opt-in e-mails.  From the Form Control dialog simply select the Check Box control (the Form control, not ActiveX), then draw it on your worksheet with the mouse.</span></div>
</div>
<div><span style="font-family: Calibri;"> </span></div>
<div id="attachment_496" class="wp-caption aligncenter" style="width: 244px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/CheckBox1.jpg"><img class="size-full wp-image-496" title="CheckBox" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/CheckBox1.jpg" alt="" width="234" height="94" /></a><p class="wp-caption-text">Check Box Form Control</p></div>
<div>
<div><span style="font-family: Calibri;">From here you can right-click the Check Box to gain access to its internal controls and formatting.  Obviously you want to edit the text to suit your needs, but you can also do things like linking the control to a particular cell.  When checked the control has a value of “TRUE”, and when unchecked its value is “FALSE”, so you can perform calculations against that. Most of the time you’ll put the linked cell in either a location away from the form itself, or format its text color to match the form background so it doesn’t display.  If a user doesn’t need to see the TRUE/FALSE value, then don’t show it to them.  There’s no need to confuse people by displaying something that they don’t need to see.</span></div>
<div><span style="font-family: Calibri;"> </span></div>
</div>
<div id="attachment_497" class="wp-caption aligncenter" style="width: 459px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/FormatControl.jpg"><img class="size-full wp-image-497" title="FormatControl" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/FormatControl.jpg" alt="" width="449" height="366" /></a><p class="wp-caption-text">Format your Form Control</p></div>
<div>
<div><span style="font-family: Calibri;">In this case the Check Box is linked to cell B11, which will toggle/display TRUE/FALSE depending on whether it’s checked or not.  As you see in the Value options, you can decide whether the Check Box’s initial state should be Checked or Unchecked.  A quick note on formatting is that you can’t change the font size with Form controls.  That’s controlled strictly by the active worksheet’s Zoom setting.  On the other hand, you can manipulate font attributes with ActiveX controls.</span></div>
<div><span style="font-family: Calibri;"> </span></div>
</div>
<div id="attachment_498" class="wp-caption aligncenter" style="width: 462px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/CheckBoxResult.jpg"><img class="size-full wp-image-498" title="CheckBoxResult" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/CheckBoxResult.jpg" alt="" width="452" height="240" /></a><p class="wp-caption-text">Using a Formula based on a Check Box&#39;s value</p></div>
<div>
<div><span style="font-family: Calibri;">In this example the formula in cell A15 simply reads: </span></div>
</div>
<div>
<div style="padding-left: 30px;"><span style="font-family: Times New Roman; font-size: small;"> </span><span style="color: #3366ff;"><em><span style="font-family: Calibri;">=&#8221;This customer &#8220;&amp;IF(B11=TRUE,&#8221;does&#8221;,&#8221;does not&#8221;)&amp;&#8221; want to receive e-mail communication.&#8221;</span></em></span></div>
</div>
<div>
<div><span style="font-family: Calibri;">This is another example of using concatenation to create custom messages for your users, or perform calculations that they might otherwise need to do manually.  Granted, these are simple examples, but they should give you an idea of what you can do.  If anything it will help you realize how you can set things up in a time-saving and well thought out fashion to make it easier to collect information from people.  The other thing it does is greatly reduce errors, which directly equates to bottom line savings. </span></div>
</div>
<div>
<div><em><span style="color: #4f81bd; font-family: Cambria;">Review &#8211; </span></em><span style="font-family: Calibri;">in this article we discussed the various elements that you can employ to streamline data collection processes without having to purchase an expensive purpose-built form creation software application simply by using tools readily available to you in Excel.  You’ll find loads of great example forms on the internet that are free for you to use, modify and distribute as you see fit.  Most notably is the Microsoft Template Gallery, which you’ll find here: </span><a href="http://office.microsoft.com/en-us/templates/"><span style="color: #0000ff; font-family: Calibri;">http://office.microsoft.com/en-us/templates/</span></a><span style="font-family: Calibri;">.  The key points to remember about building effective forms in Excel are relatively simple:</span></div>
<ul>
<li><span style="font-family: Calibri;">If you make it hard for people to give you data, then they’ll make it hard for you to get it, so be creative, and design forms with the end user in mind.  If you focus on HOW the user interacts with your form, then the data flow will be easy.  If you focus on just getting the information with little or no regard to their interaction/process then you’re all in for a miserable experience.</span></li>
<li><span style="font-family: Calibri;">A well-built and intelligently designed form can greatly reduce errors, and allow your users to give you information much faster than if they had to write it out by hand, or perform manual calculations on their own.</span></li>
<li><span style="font-family: Calibri;">Use the tools that you have available to you, Worksheet Protection, Data Validation, Conditional and Custom Cell Formatting, and Worksheet Formulas and Controls.</span></li>
</ul>
<div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span><span style="font-family: Times New Roman; font-size: small;"> </span><span style="font-family: Times New Roman; font-size: small;"> Here&#8217;s a link to the sample workbook: <a href="http://sdrv.ms/PHXUm1">http://sdrv.ms/PHXUm1</a></span></div>
<div><span style="font-family: Calibri;"><em><span style="color: #4f81bd;"> </span></em></span></div>
<div><span style="font-family: Calibri;"><em><span style="color: #4f81bd;">Chris “Smitty” Smith is Director of Training and a Developer for the boutique consulting firm </span></em><a href="http://www.excelandaccess.com/"><span style="color: #0000ff;">www.excelandaccess.com</span></a></span></div>
</div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><em><span style="color: #4f81bd; font-family: Calibri;"> </span></em></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div><strong><em><span style="color: #4f81bd; font-family: Calibri; font-size: small;"> </span></em></strong></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
</div>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/home/?status=Creating+Effective+Forms+with+Excel+%E2%80%93+The+Worksheet+Form+%28Part+2+of+3%29+http%3A%2F%2Fis.gd%2FrnazWF" title="Post to Twitter"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.smittypro.com/Blog/?p=476&amp;t=Creating+Effective+Forms+with+Excel+%E2%80%93+The+Worksheet+Form+%28Part+2+of+3%29" title="Post to Facebook"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.google.com/buzz/post?url=http://www.smittypro.com/Blog/?p=476&amp;imageurl=" title="Post to Google Buzz"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/gbuzz/tt-gbuzz-micro3.png" alt="Post to Google Buzz" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.smittypro.com/Blog/?p=476&amp;title=Creating+Effective+Forms+with+Excel+%E2%80%93+The+Worksheet+Form+%28Part+2+of+3%29&amp;summary=%0D%0A+Note%3A+this+article+was+written+specifically+for+Excel+2010+and+its+Ribbon+interface%2C+however+the+concepts+reviewed+will+apply+for+the+most+part+...&amp;source=SmittyPro" title="Post to LinkedIn"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin-micro3.png" alt="Post to LinkedIn" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://technorati.com/faves?add=http://www.smittypro.com/Blog/?p=476" title="Post to Technorati"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati-micro3.png" alt="Post to Technorati" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.smittypro.com/Blog/?feed=rss2&#038;p=476</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Effective Forms with Excel &#8211; The Simple Data Form (Part 1 of 3)</title>
		<link>http://www.smittypro.com/Blog/?p=459</link>
		<comments>http://www.smittypro.com/Blog/?p=459#comments</comments>
		<pubDate>Mon, 09 Jul 2012 00:30:52 +0000</pubDate>
		<dc:creator>"Smitty"</dc:creator>
				<category><![CDATA[Office Online Articles]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.smittypro.com/Blog/?p=459</guid>
		<description><![CDATA[Have you ever gotten an online form from a company or government organization and received a PDF that you had to print out and fill out by hand (and you’ve probably even seen one that looks like a scan of a scan of a poorly built form on an old IBM typewriter)?  What’s the point?  [...]]]></description>
			<content:encoded><![CDATA[<div class="al2fb_like_button"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like ref="AL2FB" layout="box_count" show_faces="true" width="450" action="like" colorscheme="light" href="http://www.smittypro.com/Blog/?p=459"></fb:like></div><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/home/?status=Creating+Effective+Forms+with+Excel+%E2%80%93+The+Simple+Data+Form+%28Part+1+of+3%29+http%3A%2F%2Fis.gd%2F6N7CFT" title="Post to Twitter"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.smittypro.com/Blog/?p=459&amp;t=Creating+Effective+Forms+with+Excel+%E2%80%93+The+Simple+Data+Form+%28Part+1+of+3%29" title="Post to Facebook"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.google.com/buzz/post?url=http://www.smittypro.com/Blog/?p=459&amp;imageurl=" title="Post to Google Buzz"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/gbuzz/tt-gbuzz-micro3.png" alt="Post to Google Buzz" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.smittypro.com/Blog/?p=459&amp;title=Creating+Effective+Forms+with+Excel+%E2%80%93+The+Simple+Data+Form+%28Part+1+of+3%29&amp;summary=+Have+you+ever+gotten+an+online+form+from+a+company+or+government+organization+and+received+a+PDF+that+you+had+to+print+out+and+fill+out+by+hand+%28a...&amp;source=SmittyPro" title="Post to LinkedIn"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin-micro3.png" alt="Post to LinkedIn" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://technorati.com/faves?add=http://www.smittypro.com/Blog/?p=459" title="Post to Technorati"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati-micro3.png" alt="Post to Technorati" /></a></p></div><p>
<div><span style="font-family: Times New Roman; font-size: small;"> </span><span style="font-family: Calibri;">Have you ever gotten an online form from a company or government organization and received a PDF that you had to print out and fill out by hand (and you’ve probably even seen one that looks like a scan of a scan of a poorly built form on an old IBM typewriter)?  What’s the point?  If the point is to be able to use an electronic medium, then what purpose is served by making you print something and fill it out by hand?  Not only does that process waste your time, think about what happens on the other end: you print out the form, fill it out, scan/fax/mail it, then when it gets back to the other side what do they do?  Put all of that information back into a computer.  What a monumental, no colossal, waste of time (not to mention the time that needs to be spent trying to error check your/my lousy handwriting)!  So why do people make it so hard to get information from each other?  The answer isn’t simple, but the solution is:<br />
</span></div>
</p>
<p>
<div style="padding-left: 30px;"><span style="font-family: Times New Roman; font-size: small;"> </span><em><strong><span style="color: #0000ff; font-family: Calibri;">Build a fillable form!<br />
</span></strong></em></div>
</p>
<p>
<div><span style="font-family: Calibri;">There are many software applications that are purpose built for form building, but unless you build forms for a living you need not go to the expense.  If you have Microsoft Office, which most of us do, you can easily build a form in Excel, which is ubiquitously seen in the business world as a form tool (oh, and some of us use it for financial analysis).  But it’s an amazingly effective form building tool, and allows us to keep information in the electronic/digital environment, after all, once information is put into a computer, there’s no need for that work to be redone by hand!<br />
</span></div>
</p>
<p>
<div><span style="font-family: Times New Roman; font-size: small;"> </span><span style="font-family: Calibri;">So what is a form?  Simply put, a form is a medium into which you enter information.  We all have to fill them out, DMV registration, passport applications, opening bank accounts, online flight bookings, etc.  But what’s the biggest problem with doing we generally encounter with any of these processes?  The lack of intelligent design and structure is the problem.  Printed/non-digital forms notwithstanding, have you ever gone to an online form to buy something, or book a flight and the tab order is out of sequence, or not logical at all?  (For those of you who navigate forms with the mouse, here’s a hint: use the TAB key)  We all have, and it’s frustrating, but it can all be avoided if you simply understand that the easiest way to get concise information from people is to make it <strong><em><span style="text-decoration: underline;">easy</span></em></strong> for them to give it to you.  If you make it hard for them to do that, then they will make it hard for you.  So which would you rather do?  Save time and make it easy, or make the experience painful for everyone?  Unfortunately, too many forms are seemingly built with the latter in mind.</span><span style="font-family: Times New Roman; font-size: small;"><br />
</span><span style="font-family: Calibri;"> </span></div>
</p>
<p>
<div><span style="font-family: Calibri;">Like it or not, data collection and management is central to almost everything we do, be it keeping track of personal finances, managing aspects of a business, or even booking a vacation.  Unfortunately, most organizations make it difficult for you to give and get information (big corporations and governments most notably), so we’re going to discuss how to keep it simple with one tool that most of us have at our fingertips.  Excel.<br />
</span></div>
</p>
<p>
<div><span style="font-family: Times New Roman; font-size: small;"> </span><span style="font-family: Calibri;">There are two primary types of forms and the way in which you use them.  The first is a form that allows you to capture continuous information, like keeping track of a check register or vehicle service history.  This type of information is stored with columns holding relevant transactional details, like Date, Check Number, Payee, Amount, etc., while rows store individual records, or transactions.  The second is a single use form, like an employment application, invoice or little league sign-up.  This type of form usually requires input in various places on a worksheet.  Note that a single-use form can be created in such a way as to capture transactional details, but doing so requires VBA (Visual Basic for Applications) programming, which we’re not going to discuss as part of this series.</span></div>
</p>
<p>
<div><span style="font-family: Calibri;">In this article we’re going to discuss the simplest way to create a continuous form in Excel, which is to use the Data</span>à<span style="font-family: Calibri;">Form method (a built-in functionality in Excel).  However, it’s not very robust, and only supports a limited number of data fields, but it can be a great tool for allowing people to quickly enter data.  Unfortunately, it’s one of those features that Microsoft chose to hide in Excel 2010, so you have to find it. We’ll show you that in a minute, first here’s an example of the Data Form:</span></div>
</p>
<p>
<div><span style="font-family: Times New Roman; font-size: small;"> </span><span style="font-family: Calibri;">That’s about as easy as it gets, but it’s not robust in that there’s no way to prevent users from entering incorrect information, so this should only be used for very simple data collection needs.  Otherwise you can spend as much time validating what your users entered as you would entering it by hand, knowing what needs to go where, and how.  Note in the example how the data is clearly structured with each column storing a different type of information, while each row represents a unique record.  One nice thing about this structure is that it readily lends itself to being represented as a Pivot Table or Chart, which are great ways to analyze your data, and display it graphically.</span></div>
<div><span style="font-family: Calibri;">Note: good data at the end is only as good as the data going in!</span></div>
</p>
<p>
<div><span style="font-family: Calibri;">To expose the Data Form tool in Excel 2010 goto the Quick Action Toolbar above the Ribbon, select the drop-down for more options, then the More Commands option.</span></div>
</p>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div id="attachment_460" class="wp-caption aligncenter" style="width: 273px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/QAT.jpg"><img class="size-full wp-image-460" title="Quick Action Toolbar" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/QAT.jpg" alt="" width="263" height="68" /></a><p class="wp-caption-text">QAT</p></div>
<div><span style="font-family: Calibri;">Once you do that the Customize Ribbon dialog will appear, in the left-hand pane select All Commands, then find “Form” and drag it to the right hand pane like you see here:</span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div id="attachment_464" class="wp-caption aligncenter" style="width: 210px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/QAT11.jpg"><img class="size-full wp-image-464" title="QAT1" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/QAT11.jpg" alt="" width="200" height="357" /></a><p class="wp-caption-text">Customize the QAT - More Commands</p></div>
<div><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/QAT1.jpg"></a></div>
<div><span style="font-family: Calibri;"> </span></div>
<div><span style="font-family: Calibri;"> </span></div>
<div id="attachment_463" class="wp-caption aligncenter" style="width: 874px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/CustomizeQAT.jpg"><img class="size-full wp-image-463" title="CustomizeQAT" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/CustomizeQAT.jpg" alt="" width="864" height="700" /></a><p class="wp-caption-text">Add the Data Form to the QAT</p></div>
<div><span style="font-family: Calibri;">From here on out, anytime you’re in a data set that Excel can recognize when you click on the Form button the Data Form will appear.  But there are some simple rules for using this tool: first, your data needs to be structured in such a way that Excel can read and understand it (in much the same way that your users need to understand what’s expected of them).  So your worksheet needs to be set up in a contiguous manner, meaning that if you have empty columns or rows in your worksheet, then don’t expect Excel to pick it up (then again, don’t expect your users to either).  Second, you need to have column headers for the form to be able to identify, and as you saw in the Data Form example, Excel uses the first row in your worksheet to define the entry fields.  Third, if you have more data fields then the form can accept, this won’t be the appropriate tool for you (but we’ll discuss that in the next article).  Fourth, and key to intelligent form design is to layout your worksheet in such a way that makes sense for data collection and use once you get it, which means that individual records should ideally be stored in a series of rows going down the worksheet, not columns going across, as columns should be used for individual components of each overall record (row).  Also think about Excel’s capabilities: while you now have over 1 million rows of data, you “only” have 16,000 columns.  If you were to collect data in columns as opposed to rows, you could run out of room.  Unfortunately, we see this type of structure all too often, so you can avoid the pain of having to rebuild a workbook just by building it right in the first place.  Here&#8217;s an example of the simple Data Form in use:</span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div>
<div id="attachment_462" class="wp-caption aligncenter" style="width: 444px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/DataFormExample.jpg"><img class="size-full wp-image-462" title="Data Form Example" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/DataFormExample.jpg" alt="" width="434" height="513" /></a><p class="wp-caption-text">Data Form Example</p></div>
<p>
<div><span style="font-family: Calibri;">Notice that your column headers do have Accelerators attached to them.  Those are the underlines beneath the S in Store, a in Date, etc.  To quickly acces any of those fields directly from the keyboard, all you need to do it press ALT+ the corresponding letter for that field.  I&#8217;ve never tried to push one of these forms to its field limit, but I&#8217;d imagine that you&#8217;re going to run out of Accelerators when you get beyond 26 fields (corresponding with 26 letters in the alphabet).</span></div>
</p>
<p>
<div><span style="font-family: Calibri;">If you do like the Data Form, but need a more robust version, longtime Excel MVP John Walkenbach has a free add-in he created called the Enhanced Data Form.  You can find it here: <a href="http://spreadsheetpage.com/index.php/dataform/home"><span style="color: #0000ff;">http://spreadsheetpage.com/index.php/dataform/home</span></a>.</span></div>
</p>
<div><span style="font-family: Calibri;"> </span></div>
<div id="attachment_465" class="wp-caption aligncenter" style="width: 480px"><a href="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/JWalkEnhancedDataForm.jpg"><img class="size-full wp-image-465" title="JWalkEnhancedDataForm" src="http://www.smittypro.com/Blog/wp-content/uploads/2012/07/JWalkEnhancedDataForm.jpg" alt="" width="470" height="378" /></a><p class="wp-caption-text">John Walkenbach&#39;s Enhanced Data Form</p></div>
<div>You can find a copy of the Simple Data Form workbook here: <a href="http://sdrv.ms/OLHFSh">http://sdrv.ms/OLHFSh</a>.  Note that it contains a simple macro attached to a button to display the form in case you haven&#8217;t exposed the Data Form button on the QAT, which will require you to enable macros.  In versions of Excel prior to Excel 2007, the Data Form is available from the Data menu.</div>
<p>
<div><span style="font-family: Calibri;">In the next article we’ll discuss building single-use forms, like an invoice, or employee expense report.</span></div>
<div><span style="font-family: Times New Roman; font-size: small;"> </span></div></p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/home/?status=Creating+Effective+Forms+with+Excel+%E2%80%93+The+Simple+Data+Form+%28Part+1+of+3%29+http%3A%2F%2Fis.gd%2F6N7CFT" title="Post to Twitter"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.smittypro.com/Blog/?p=459&amp;t=Creating+Effective+Forms+with+Excel+%E2%80%93+The+Simple+Data+Form+%28Part+1+of+3%29" title="Post to Facebook"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.google.com/buzz/post?url=http://www.smittypro.com/Blog/?p=459&amp;imageurl=" title="Post to Google Buzz"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/gbuzz/tt-gbuzz-micro3.png" alt="Post to Google Buzz" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.smittypro.com/Blog/?p=459&amp;title=Creating+Effective+Forms+with+Excel+%E2%80%93+The+Simple+Data+Form+%28Part+1+of+3%29&amp;summary=+Have+you+ever+gotten+an+online+form+from+a+company+or+government+organization+and+received+a+PDF+that+you+had+to+print+out+and+fill+out+by+hand+%28a...&amp;source=SmittyPro" title="Post to LinkedIn"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin-micro3.png" alt="Post to LinkedIn" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://technorati.com/faves?add=http://www.smittypro.com/Blog/?p=459" title="Post to Technorati"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati-micro3.png" alt="Post to Technorati" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.smittypro.com/Blog/?feed=rss2&#038;p=459</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Excel: Automatically consolidate data from multiple worksheets?</title>
		<link>http://www.smittypro.com/Blog/?p=451</link>
		<comments>http://www.smittypro.com/Blog/?p=451#comments</comments>
		<pubDate>Tue, 05 Jun 2012 17:44:51 +0000</pubDate>
		<dc:creator>"Smitty"</dc:creator>
				<category><![CDATA[Office Automation]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.smittypro.com/Blog/?p=451</guid>
		<description><![CDATA[We had a question at #ExcelHelp this week from somone who wanted to consolidate data from multiple worksheets to a master sheet. My first thougt was use Excel&#8217;s native PivotTable functionality for multiple consolidations ranges (easier than it sounds, just follow the Wizard), but this case just needed to move an inconsistent range of worksheets [...]]]></description>
			<content:encoded><![CDATA[<div class="al2fb_like_button"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like ref="AL2FB" layout="box_count" show_faces="true" width="450" action="like" colorscheme="light" href="http://www.smittypro.com/Blog/?p=451"></fb:like></div><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/home/?status=Excel%3A+Automatically+consolidate+data+from+multiple+worksheets%3F+http%3A%2F%2Fis.gd%2FBwJMNB" title="Post to Twitter"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.smittypro.com/Blog/?p=451&amp;t=Excel%3A+Automatically+consolidate+data+from+multiple+worksheets%3F" title="Post to Facebook"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.google.com/buzz/post?url=http://www.smittypro.com/Blog/?p=451&amp;imageurl=" title="Post to Google Buzz"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/gbuzz/tt-gbuzz-micro3.png" alt="Post to Google Buzz" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.smittypro.com/Blog/?p=451&amp;title=Excel%3A+Automatically+consolidate+data+from+multiple+worksheets%3F&amp;summary=We+had+a+question+at+%23ExcelHelp+this+week+from+somone+who+wanted+to+consolidate+data+from+multiple+worksheets+to+a+master+sheet.++My+first+thougt+w...&amp;source=SmittyPro" title="Post to LinkedIn"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin-micro3.png" alt="Post to LinkedIn" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://technorati.com/faves?add=http://www.smittypro.com/Blog/?p=451" title="Post to Technorati"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati-micro3.png" alt="Post to Technorati" /></a></p></div><p><strong>
<div>We had a question at #ExcelHelp this week from somone who wanted to consolidate data from multiple worksheets to a master sheet.  My first thougt was use Excel&#8217;s native PivotTable functionality for multiple consolidations ranges (easier than it sounds, just follow the Wizard), but this case just needed to move an inconsistent range of worksheets just a few times, so VBA code seemed more appropriate for a one-off situation like this where you copy data from each worksheet to the master.  The problem (especially if you&#8217;re just starting with VBA) is that one worksheet might have 52 rows of data and the next 73, or 1,008.  So how do you deal with dynamic ranges like that?  Unfortunately, this isn&#8217;t one that the Macro Recorder can take care of for you, so you need to go beyond that and actually start writing some code of your own, but this is where VBA&#8217;s power shines; you just need to know how to tap into it&#8230;</div>
</p>
<p>
<div>What might seem very complicated, really just needs a bit of thought and some dynamic ranging, so we can identify the range of data in each worksheet to be copied (A2:A1274 let&#8217;s say).  But that just defines the copy from range, then we need to identify the first empty row in the worksheet where the data is going to be copied, and each time new rows of data are added, we need to find the new last row.  Within all of that we&#8217;ll go through each worksheet and then redifine those ranges.</div>
</p>
<p>
<div>Here&#8217;s the resulting code, with comments so you can see what it&#8217;s doing:</div>
</p>
<div></div>
<p>
<div><code>Sub CopyfromSheets()<br />
<span style="color: #008000;">'	Declare Variables for Worksheets &amp; lr to get the last used row in a range</span><br />
Dim ws As Worksheet<br />
Dim lr As Long</code></div>
<p><code></p>
<div><span style="color: #008000;">'	Loop through each worksheet in the workbook</span><br />
For Each ws In ActiveWorkbook.Worksheets<br />
<span style="color: #008000;"> '	 Tell the code to ignore the "Master" worksheet</span><br />
If ws.Name &lt;&gt; "Master" Then<br />
<span style="color: #008000;"> '	Find the last used row in column A in each sheet</span><br />
lr = ws.Cells(Rows.Count, "A").End(xlUp).Row<br />
<span style="color: #008000;"> '	Rows.Count counts the number of rows in the worksheet and doesn't care if it's 65,536 or 1MM+.</span><br />
<span style="color: #008000;"> '	 End(xlUp) goes from the last row at the bottom up to the last row at the top</span><br />
<span style="color: #008000;"> '	You can also use End(xlDown), but it will fall apart if you have blank rows in your data</span><br />
<span style="color: #008000;"> '	.Row gets the Row #, so "lr" can then be 52, 74, 1,008, etc., as it resets for each worksheet</span><br />
<span style="color: #008000;"> </span></div>
<div><span style="color: #008000;"> '	Copy/Paste - As long as you're not trying to Paste Special, like Values, then you can have Range.Copy --&gt;Destination all on one line</span><br />
<span style="color: #008000;"> '	In the Paste part we use Offset(1) to move down to the next Empty row so you don't paste over existing data</span><br />
ws.Range("A2:A" &amp; lr).Copy Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Offset(1)<br />
<span style="color: #008000;"> '	Exit the IF statement evaluating the sheet name</span><br />
End If<br />
<span style="color: #008000;"> '	Move on to the next worksheet.  This doesn't care how many sheets you have, as it will go through them all</span><br />
<span style="color: #008000;"> '	If you only wanted to do this on 20 of 100 sheets you can define the For Each Next construct like this:</span><br />
<span style="color: #008000;"> '	For i = 10 to 30</span><br />
<span style="color: #008000;"> '	Sheets(i)...</span><br />
<span style="color: #008000;"> '	Next i</span><br />
<span style="color: #008000;"> '	Which goes from sheet #10 to sheet #30 and ignores any others</span><br />
Next ws<br />
End Sub</div>
<p></code></p>
<p>
<div>So now you have a way to dynamically copy data from multiple worksheets to a master sheet.  And while this is a relatively simple example, it wouldn&#8217;t be hard to set it up to copy multiple columns.  You could even set it up for a variable number of columns by adding the same methodology used to identify the last row:</div>
</p>
<div>lc = Cells(1,Columns.Count).End(xlToLeft).Column</div>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/home/?status=Excel%3A+Automatically+consolidate+data+from+multiple+worksheets%3F+http%3A%2F%2Fis.gd%2FBwJMNB" title="Post to Twitter"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.smittypro.com/Blog/?p=451&amp;t=Excel%3A+Automatically+consolidate+data+from+multiple+worksheets%3F" title="Post to Facebook"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.google.com/buzz/post?url=http://www.smittypro.com/Blog/?p=451&amp;imageurl=" title="Post to Google Buzz"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/gbuzz/tt-gbuzz-micro3.png" alt="Post to Google Buzz" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.smittypro.com/Blog/?p=451&amp;title=Excel%3A+Automatically+consolidate+data+from+multiple+worksheets%3F&amp;summary=We+had+a+question+at+%23ExcelHelp+this+week+from+somone+who+wanted+to+consolidate+data+from+multiple+worksheets+to+a+master+sheet.++My+first+thougt+w...&amp;source=SmittyPro" title="Post to LinkedIn"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin-micro3.png" alt="Post to LinkedIn" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://technorati.com/faves?add=http://www.smittypro.com/Blog/?p=451" title="Post to Technorati"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati-micro3.png" alt="Post to Technorati" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.smittypro.com/Blog/?feed=rss2&#038;p=451</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Excel VBA Training &amp; Certification</title>
		<link>http://www.smittypro.com/Blog/?p=439</link>
		<comments>http://www.smittypro.com/Blog/?p=439#comments</comments>
		<pubDate>Mon, 07 May 2012 19:50:09 +0000</pubDate>
		<dc:creator>"Smitty"</dc:creator>
				<category><![CDATA[Office Automation]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.smittypro.com/Blog/?p=439</guid>
		<description><![CDATA[If you&#8217;ve followed any of our posts, then you&#8217;ll see that we&#8217;re huge proponents of using VBA (Visual Basic for Applications) as a means of automating everyday tasks in the Office environment. One of the most frequent forum comments/requests that we see is for how to learn VBA. Most of the advice that you&#8217;ll get [...]]]></description>
			<content:encoded><![CDATA[<div class="al2fb_like_button"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like ref="AL2FB" layout="box_count" show_faces="true" width="450" action="like" colorscheme="light" href="http://www.smittypro.com/Blog/?p=439"></fb:like></div><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/home/?status=Excel+VBA+Training+%26+Certification+http%3A%2F%2Fis.gd%2FZ5EGHL" title="Post to Twitter"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.smittypro.com/Blog/?p=439&amp;t=Excel+VBA+Training+%26+Certification" title="Post to Facebook"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.google.com/buzz/post?url=http://www.smittypro.com/Blog/?p=439&amp;imageurl=" title="Post to Google Buzz"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/gbuzz/tt-gbuzz-micro3.png" alt="Post to Google Buzz" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.smittypro.com/Blog/?p=439&amp;title=Excel+VBA+Training+%26+Certification&amp;summary=If+you%27ve+followed+any+of+our+posts%2C+then+you%27ll+see+that+we%27re+huge+proponents+of+using+VBA+%28Visual+Basic+for+Applications%29+as+a+means+of+automati...&amp;source=SmittyPro" title="Post to LinkedIn"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin-micro3.png" alt="Post to LinkedIn" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://technorati.com/faves?add=http://www.smittypro.com/Blog/?p=439" title="Post to Technorati"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati-micro3.png" alt="Post to Technorati" /></a></p></div><p>If you&#8217;ve followed any of our posts, then you&#8217;ll see that we&#8217;re huge proponents of using VBA (Visual Basic for Applications) as a means of automating everyday tasks in the Office environment.</p>
<p>One of the most frequent forum comments/requests that we see is for how to learn VBA.  Most of the advice that you&#8217;ll get starts with your most valuable free tool, which is the macro recorder.  Then there are lots of online tutorials you&#8217;ll find via Bing/Google, and finally you can buy some books (John Walkenbach&#8217;s Power Programming with Excel VBA is the best).  But what if you want to step up your game and actually get certified in VBA?  </p>
<p>Well, look no further than <a href="http://www.vbaexpress.com/training/">http://www.vbaexpress.com/training/</a>.  The folks over there have done an amazing job of not only creating fantastic VBA courseware, but they offer the ability to be certified in VBA as well.</p>
<p>If you want to step up to your &#8220;A&#8221; game then you can use the following coupon codes to get a discount:</p>
<p><em><strong>SP10OFFTRAINING</strong></em> and <em><strong>SP5OFFCERTIFICATION</strong></em></p>
<p>A word of caution here though: I&#8217;ve had the pleasure of being a tech editor for some of the content and it&#8217;s not for the faint-of-heart.  This is serious stuff.  But you&#8217;ll without a doubt walk away being the best VBA user around.  And while we&#8217;re not tax professionals, we&#8217;ll bet good odds that it&#8217;s tax deductible.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/home/?status=Excel+VBA+Training+%26+Certification+http%3A%2F%2Fis.gd%2FZ5EGHL" title="Post to Twitter"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.smittypro.com/Blog/?p=439&amp;t=Excel+VBA+Training+%26+Certification" title="Post to Facebook"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.google.com/buzz/post?url=http://www.smittypro.com/Blog/?p=439&amp;imageurl=" title="Post to Google Buzz"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/gbuzz/tt-gbuzz-micro3.png" alt="Post to Google Buzz" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.smittypro.com/Blog/?p=439&amp;title=Excel+VBA+Training+%26+Certification&amp;summary=If+you%27ve+followed+any+of+our+posts%2C+then+you%27ll+see+that+we%27re+huge+proponents+of+using+VBA+%28Visual+Basic+for+Applications%29+as+a+means+of+automati...&amp;source=SmittyPro" title="Post to LinkedIn"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin-micro3.png" alt="Post to LinkedIn" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://technorati.com/faves?add=http://www.smittypro.com/Blog/?p=439" title="Post to Technorati"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati-micro3.png" alt="Post to Technorati" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.smittypro.com/Blog/?feed=rss2&#038;p=439</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VB HTML Maker Update</title>
		<link>http://www.smittypro.com/Blog/?p=401</link>
		<comments>http://www.smittypro.com/Blog/?p=401#comments</comments>
		<pubDate>Wed, 25 Apr 2012 02:43:58 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Office Automation]]></category>
		<category><![CDATA[Office Online Articles]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.smittypro.com/Blog/?p=401</guid>
		<description><![CDATA[When I first starting really getting into VBA, it was pretty invaluable to me to be able to read over my code. And over and over and over my code again. And again. As well as others code. This really helped me learn the syntax and flow. An add-in which was great, which I can&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<div class="al2fb_like_button"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like ref="AL2FB" layout="box_count" show_faces="true" width="450" action="like" colorscheme="light" href="http://www.smittypro.com/Blog/?p=401"></fb:like></div><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/home/?status=VB+HTML+Maker+Update+http%3A%2F%2Fis.gd%2FZ1wIIK" title="Post to Twitter"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.smittypro.com/Blog/?p=401&amp;t=VB+HTML+Maker+Update" title="Post to Facebook"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.google.com/buzz/post?url=http://www.smittypro.com/Blog/?p=401&amp;imageurl=" title="Post to Google Buzz"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/gbuzz/tt-gbuzz-micro3.png" alt="Post to Google Buzz" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.smittypro.com/Blog/?p=401&amp;title=VB+HTML+Maker+Update&amp;summary=When+I+first+starting+really+getting+into+VBA%2C+it+was+pretty+invaluable+to+me+to+be+able+to+read+over+my+code.++And+over+and+over+and+over+my+code+...&amp;source=SmittyPro" title="Post to LinkedIn"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin-micro3.png" alt="Post to LinkedIn" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://technorati.com/faves?add=http://www.smittypro.com/Blog/?p=401" title="Post to Technorati"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati-micro3.png" alt="Post to Technorati" /></a></p></div><p>When I first starting really getting into VBA, it was pretty invaluable to me to be able to read over my code.  And over and over and over my code again.  And again.  As well as others code.  This really helped me learn the syntax and flow.  An add-in which was great, which I can&#8217;t remember the name of, allowed me to print out my VBA code as an HTML file, so I could view the code as it looked in the VBIDE.  This was great!  I could now review my code <em>and </em>keep it as a hard copy for backup!</p>
<p>In the meantime, I have done a lot of posting to forums of sorts.  One of the forums in particular is <a href="http://www.mrexcel.com/forum/index.php">Mr Excel.com</a>.  This board utilizes vBulletin software and is laid out very nicely.  There are a few add-ins to help you post things to make it present nicely when viewed.  Some of these add-ins were (a list of which can be found <a href="http://www.mrexcel.com/forum/showthread.php?t=126629">here</a>) Colo&#8217;s HTMLMaker, <a href="http://www.excel-jeanie-html.de/index.php?f=1">Excel Jeanie 4</a>, <a href="http://www.asap-utilities.com/">ASAP Utilities</a>, etc.  Among these was the VBHTMLMaker add-in, which let you post your VBA code to the forum and have it present as it did in the IDE.  Awesome!</p>
<p>So now to my point.  A few years ago I asked Juan Pablo González, original developer of the VBHTMLMaker add-in (amongst other collaborators) if I could amend his add-in.  What I wanted to do was add an option to save the HTML generated code into an HTML file.  Easy, portable, documented, and printable!  He graciously agreed and that&#8217;s where I sat until yesterday.  I made excuses that I didn&#8217;t have time, but more or less I didn&#8217;t make it a priority.  I finally had enough with my procrastination and I added the code yesterday, tested today, and am now uploading to share with the world.</p>
<p>There is also some minor modifications to keep it as the font you have set in your VBE options.  To get this value we need to read the registry, which retains the font name (among properties).  A portion of the code was graciously utilized from Dev Ashish and Terry Kreft.  This is used by the following code:</p>
<p><font face="Verdana"><SPAN style="color:#007F00">&#8216;&#160;&#160;&#160;&#160;Txt = IIf(HTML, &#8220;<font face="Courier">&#8220;, &#8220;[face=Courier New]&#8220;)</SPAN><br />&#160;&#160;&#160;&#160;Txt = IIf(HTML, &#8220;<font face=" &amp; sFontName &amp; ">&#8220;, &#8220;[face=Courier New]&#8220;)</FONT></p>
<p>If you do not want to use such code and want it in Courier New every time, uncomment the commented line and take out the other.  Unfortunately this only works for HTML and not BB code.  The new file is named VBHTMLMaker2007, but does not utilize the Ribbon in any way.  So if you have a need or desire to save your VBA as an HTML file for whatever reason, this file has the amended code as such.  Enjoy!</p>
<p><a href='http://www.smittypro.com/Blog/wp-content/uploads/2012/01/VBHTMLMaker2007.zip'>VBHTMLMaker2007</a></p>
<p>Regards,</p>
<p>Zack Barresse</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/home/?status=VB+HTML+Maker+Update+http%3A%2F%2Fis.gd%2FZ1wIIK" title="Post to Twitter"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.smittypro.com/Blog/?p=401&amp;t=VB+HTML+Maker+Update" title="Post to Facebook"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.google.com/buzz/post?url=http://www.smittypro.com/Blog/?p=401&amp;imageurl=" title="Post to Google Buzz"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/gbuzz/tt-gbuzz-micro3.png" alt="Post to Google Buzz" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.smittypro.com/Blog/?p=401&amp;title=VB+HTML+Maker+Update&amp;summary=When+I+first+starting+really+getting+into+VBA%2C+it+was+pretty+invaluable+to+me+to+be+able+to+read+over+my+code.++And+over+and+over+and+over+my+code+...&amp;source=SmittyPro" title="Post to LinkedIn"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin-micro3.png" alt="Post to LinkedIn" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://technorati.com/faves?add=http://www.smittypro.com/Blog/?p=401" title="Post to Technorati"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati-micro3.png" alt="Post to Technorati" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.smittypro.com/Blog/?feed=rss2&#038;p=401</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a Table of Contents in Excel</title>
		<link>http://www.smittypro.com/Blog/?p=409</link>
		<comments>http://www.smittypro.com/Blog/?p=409#comments</comments>
		<pubDate>Mon, 30 Jan 2012 02:28:47 +0000</pubDate>
		<dc:creator>Zack</dc:creator>
				<category><![CDATA[Office Automation]]></category>
		<category><![CDATA[Office Online Articles]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Table of Contents]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://www.smittypro.com/Blog/?p=409</guid>
		<description><![CDATA[There has always been a need for a good Table of Contents in Excel. While Word features this natively with its built-in Styles, unfortunately, Excel lacks this functionality due to a host of reasons, which are quite valid. However, we can create a workaround by incorporating some VBA. The following code is an updated version [...]]]></description>
			<content:encoded><![CDATA[<div class="al2fb_like_button"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like ref="AL2FB" layout="box_count" show_faces="true" width="450" action="like" colorscheme="light" href="http://www.smittypro.com/Blog/?p=409"></fb:like></div><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/home/?status=Create+a+Table+of+Contents+in+Excel+http%3A%2F%2Fis.gd%2FgKI7A4" title="Post to Twitter"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.smittypro.com/Blog/?p=409&amp;t=Create+a+Table+of+Contents+in+Excel" title="Post to Facebook"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.google.com/buzz/post?url=http://www.smittypro.com/Blog/?p=409&amp;imageurl=" title="Post to Google Buzz"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/gbuzz/tt-gbuzz-micro3.png" alt="Post to Google Buzz" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.smittypro.com/Blog/?p=409&amp;title=Create+a+Table+of+Contents+in+Excel&amp;summary=There+has+always+been+a+need+for+a+good+Table+of+Contents+in+Excel.++While+Word+features+this+natively+with+its+built-in+Styles%2C+unfortunately%2C+Exc...&amp;source=SmittyPro" title="Post to LinkedIn"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin-micro3.png" alt="Post to LinkedIn" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://technorati.com/faves?add=http://www.smittypro.com/Blog/?p=409" title="Post to Technorati"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati-micro3.png" alt="Post to Technorati" /></a></p></div><p>There has always been a need for a good Table of Contents in Excel.  While Word features this natively with its built-in Styles, unfortunately, Excel lacks this functionality due to a host of reasons, which are quite valid.  However, we can create a workaround by incorporating some VBA.</p>
<p>The following code is an updated version I created a few years ago.  It was simple and served my needs.  Over the years it&#8217;s needed work, but like a mechanic with his own vehicle, I never really put the time forth to do it, always pushing it to the back burner.  Not so anymore!  Today I updated the code and made it much more versatile and dynamic!  Plus I added comments, which are always helpful when looking back on it.</p>
<p>The code will now take any type of worksheet and create a hyperlink to it.  Previously, the problem was if the user had a Dialog, Macro or Chart sheet in a workbook, standard hyperlinks do not work, as you can only use a standard hyperlink to a worksheet (all of the above objects are in the Sheets collection, but not a Worksheet type).  In order to bypass this we can create a button on top of each unsupported object it which is linked to a procedure in a we have stored in a module.  You can change the variables at the top of the module to whatever you&#8217;d like, but it will work as-is if you copy/paste to a new module.  The code It will automatically change the name of the module to whatever you specify for the <em>sModuleName </em>variable.</p>
<p>Here is the code.  If you have any comments, please feel free to let me know!</p>
<p><code>'---------------------------------------------------------------------------------------<br />
' Module    : Mod_TOC_RPA<br />
' Author    : Zack Barresse<br />
' Updated   : 1/27/2012<br />
' Purpose   : This code module serves as a stand-alone module to create a Table of<br />
'             Contents of the active workbook.  The other sub routines are supportive<br />
'             of this functionality.  This will handle the following sheet types:<br />
'               Worksheets<br />
'               Chart sheets<br />
'               Dialog sheets<br />
'               Macro sheets<br />
'             For those sheets which are not Worksheet types, a shape is utilized.  This<br />
'             is done because you cannot hyperlink to these sheet types with the normal<br />
'             functionality.  So instead we add the sheet name to it with an old<br />
'             Excel4Macro and add an OnAction property for it to use a sub routine.  All<br />
'             other 'normal' worksheets will receive a hyperlink to that sheet, with a<br />
'             destination of cell A1.<br />
' References: Microsoft Visual Basic for Applications Extensibility 5.3<br />
'             You must set this reference for the code to compile without error.  To<br />
'             add this reference library, click Tools | References, find the correct<br />
'             reference, check the box next to it, then click Ok.  If you don't see it<br />
'             in the list, look for it in its normal location:<br />
'             C:\Program Files (x86)\Common Files\microsoft shared\VBA\VBA6\VBE6EXT.OLB<br />
'              or<br />
'             C:\Program Files\Common Files\microsoft shared\VBA\VBA6\VBE6EXT.OLB<br />
'             Change the 'sModuleName' to whatever you want the module to be named.<br />
'             With the above reference, you can change it to whatever you want.  If you<br />
'             name it to another module name that exists in the same project, the<br />
'             current module name will be retained.<br />
' Examples  : Some other examples of creating Table of Contents can be found here:<br />
'               http://dmcritchie.mvps.org/excel/buildtoc.htm<br />
'               http://www.vbaexpress.com/kb/getarticle.php?kb_id=120<br />
'               http://www.mrexcel.com/articles/table-of-contents-macro.php<br />
'               http://alturl.com/nrk83 **<br />
'               http://extremecpa.blogspot.com/2005/08/table-of-contents-in-excel-with-vba.html<br />
'               ** Like this code, will take any type of sheet (the others will fail),<br />
'                  but uses VBA to write to the Table of Contents sheet code module<br />
'                  for the functionality of hyperlinking.<br />
'---------------------------------------------------------------------------------------</p>
<p>Option Explicit</p>
<p>Private Const sModuleName       As String = "Module1"<br />
Private Const sDefaultProcName  As String = "CreateTOC"<br />
Private Const sSheetName        As String = "Table of Contents"<br />
Private Const DNL               As String = vbNewLine &amp; vbNewLine<br />
Private sModuleRename           As String<br />
Private sProcName               As String<br />
Private bModuleName             As Boolean</p>
<p>'/// ***************************************************************************************<br />
'/// MAIN ROUTINE<br />
'/// ***************************************************************************************</p>
<p>Sub CreateTOC()<br />
    '---------------------------------------------------------------------------------------<br />
    ' Procedure : CreateTOC<br />
    ' Author    : Zack Barresse<br />
    ' Updated   : 1/27/2012<br />
    ' Purpose   : Explicitly setting object references, cleaned up variables, added some<br />
    '             additional error handling, added the handling of Macro and Dialog sheets<br />
    '             as well, and generally cleaned up code.<br />
    'Thanks to  : Ken Puls<br />
    '             Simon Lloyd<br />
    '             Anne Troy<br />
    '---------------------------------------------------------------------------------------<br />
    Dim VBComp                  As VBIDE.VBComponent<br />
    Dim CodeMod                 As VBIDE.CodeModule<br />
    Dim LineNum                 As Long<br />
    Dim ProcKind                As VBIDE.vbext_ProcKind<br />
    Dim WB                      As Workbook<br />
    Dim WS                      As Worksheet<br />
    Dim cb                      As Shape<br />
    Dim iWriteToRow             As Long<br />
    Dim iLoop                   As Long<br />
    Dim iWsTotalCnt             As Long<br />
    Dim iWsCnt                  As Long<br />
    Dim iChartCnt               As Long<br />
    Dim iOtherCnt               As Long<br />
    Dim iLeft                   As Long<br />
    Dim iTop                    As Long<br />
    Dim iHeight                 As Long<br />
    Dim iWidth                  As Long<br />
    Dim iShade                  As Long<br />
    Dim sMsg                    As String<br />
    Dim sAddy                   As String<br />
    Dim shtName                 As String<br />
    Dim bTrigger                As Boolean</p>
<p>    '/// Used to get procedure name<br />
    bTrigger = True</p>
<p>    '/// Check if there is an activeworkbook or not (i.e. this code was dropped into a<br />
    '/// workbook which wasn't visible, or an add-in)<br />
    If ActiveWorkbook Is Nothing Then<br />
        MsgBox "You must have a workbook open first!", vbInformation, "No Open Book"<br />
        Exit Sub<br />
    End If</p>
<p>    '/// Set variables<br />
    iShade = 37<br />
    iWriteToRow = 3<br />
    iWsCnt = 0<br />
    Set WB = ActiveWorkbook</p>
<p>    '/// Turn off some application settings to make code more efficient and run faster<br />
    Call TOGGLEEVENTS(False)</p>
<p>    '/// Check if the TOC worksheet already exists in the workbook, and if so question user<br />
    If WSEXISTS(sSheetName, WB) = True Then<br />
        sMsg = "You already have a Table of Contents page. Would you like to overwrite it?"<br />
        If MsgBox(sMsg, vbYesNo + vbQuestion, "Replace TOC page?") = vbYes Then GoTo ExitEarly<br />
        WB.Worksheets(sSheetName).Delete<br />
    End If</p>
<p>    '/// Add a blank worksheet to the far left, rename it<br />
    Set WS = WB.Worksheets.Add(before:=WB.Sheets(1))<br />
    WS.Name = sSheetName</p>
<p>    '/// Ensure the code module is the proper name, as needed for the shape OnAction property<br />
    Call ChangeModuleName</p>
<p>    '/// Change format of TOC sheet<br />
    WS.Cells.Interior.ColorIndex = iShade<br />
    WS.Rows("4:" &amp; WS.Rows.Count).RowHeight = 16<br />
    WS.Range("A1").Font.Bold = False<br />
    WS.Range("A1").Font.Italic = True<br />
    WS.Range("A1").Font.Name = "Arial"<br />
    WS.Range("A1").Font.Size = "8"<br />
    WS.Range("A2").Value = "Table of Contents"<br />
    WS.Range("A2").Font.Bold = True<br />
    WS.Range("A2").Font.Name = "Arial"<br />
    WS.Range("A2").Font.Size = "24"<br />
    WS.Range("A4").Select</p>
<p>    '/// Add a shape which will act as an update for the TOC sheet<br />
    With WS.Range("C1")<br />
        Set cb = WS.Shapes.AddShape(msoShapeRoundedRectangle, .Left, .Top, .Width, .Height)<br />
    End With<br />
    sAddy = "R1C3"<br />
    cb.Select<br />
    Selection.ShapeRange.Fill.ForeColor.SchemeColor = 0<br />
    Selection.ShapeRange.TextFrame.VerticalAlignment = xlCenter<br />
    Selection.Font.Underline = xlUnderlineStyleSingle<br />
    Selection.Font.ColorIndex = 5<br />
    Selection.ShapeRange.Fill.Visible = msoFalse<br />
    Selection.ShapeRange.Line.Visible = msoFalse</p>
<p>    '/// Get the current routine name<br />
    '/// Kindly adapted from Chip Pearson, found at:<br />
    '/// http://www.cpearson.com/Excel/vbe.aspx<br />
    On Error GoTo ErrHandle<br />
    Set VBComp = ThisWorkbook.VBProject.VBComponents(sModuleName)<br />
    Set CodeMod = VBComp.CodeModule<br />
    LineNum = CodeMod.CountOfDeclarationLines + 1<br />
    sProcName = CodeMod.ProcOfLine(LineNum, ProcKind)<br />
    GoTo NoCodeModErr</p>
<p>ErrHandle:<br />
    '/// Code module was not found, use default<br />
    sProcName = sDefaultProcName</p>
<p>NoCodeModErr:<br />
    If sProcName = vbNullString Then sProcName = sDefaultProcName<br />
    Selection.OnAction = IIf(Len(sModuleRename) &gt; 0, sModuleRename, sModuleName) &amp; "." &amp; sProcName</p>
<p>    '/// Set heading text for TOC<br />
    WS.Range("C1").Value = "Update TOC"<br />
    WS.Range("C1").Interior.ColorIndex = iShade<br />
    WS.Range("C1").Font.Bold = True<br />
    WS.Range("C1").Font.Italic = True<br />
    WS.Range("C1").Font.Name = "Arial"<br />
    WS.Range("C1").Font.Size = "10"<br />
    WS.Range("C1").Font.Underline = xlUnderlineStyleSingle</p>
<p>    '/// Get a total of the sheets<br />
    '/// NB: We do not use "WB.Worksheets.Count" as that will only count 'worksheets', which<br />
    '/// does not include chart sheets<br />
    iWsTotalCnt = WB.Sheets.Count</p>
<p>    '/// Loop through all sheets, excluding the first (TOC) worksheet<br />
    For iLoop = 2 To iWsTotalCnt</p>
<p>        '/// Set the write row, increment by 1 every iteration<br />
        iWriteToRow = iWriteToRow + 1</p>
<p>        '/// Check if the sheet iteration is a chart sheet or not<br />
        If IsChart(WB.Sheets(iLoop).Name) Then</p>
<p>            '///////////////////////////<br />
            '/// Sheet is a chart sheet<br />
            '///////////////////////////</p>
<p>            '/// Get a total count of chart sheets, set variables<br />
            iChartCnt = iChartCnt + 1<br />
            shtName = WB.Charts(iChartCnt).Name<br />
            WS.Range("C" &amp; iWriteToRow).Value = shtName<br />
            WS.Range("C" &amp; iWriteToRow).Font.ColorIndex = iShade</p>
<p>            '/// Get dimensions of write cell to apply button to it<br />
            iLeft = WS.Range("C" &amp; iWriteToRow).Left<br />
            iTop = WS.Range("C" &amp; iWriteToRow).Top<br />
            iWidth = WS.Range("C" &amp; iWriteToRow).Width<br />
            iHeight = WS.Range("C" &amp; iWriteToRow).RowHeight<br />
            sAddy = "R" &amp; iWriteToRow &amp; "C3"</p>
<p>            '/// Add the shape to the correct cell, add text to it and assign macro "GotoChart"<br />
            Set cb = WS.Shapes.AddShape(msoShapeRoundedRectangle, iLeft, iTop, iWidth, iHeight)<br />
            cb.Select<br />
            ExecuteExcel4Macro "FORMULA(""=" &amp; sAddy &amp; """)"<br />
            Selection.ShapeRange.TextFrame.VerticalAlignment = xlCenter<br />
            Selection.ShapeRange.TextFrame.HorizontalAlignment = xlLeft<br />
            Selection.ShapeRange.Fill.ForeColor.SchemeColor = 0<br />
            Selection.Font.Underline = xlUnderlineStyleSingle<br />
            Selection.Font.ColorIndex = 5<br />
            Selection.ShapeRange.Fill.Visible = msoFalse<br />
            Selection.ShapeRange.Line.Visible = msoFalse<br />
            Selection.OnAction = IIf(Len(sModuleRename) &gt; 0, sModuleRename, sModuleName) &amp; ".GotoOther"</p>
<p>            '/// Write number to TOC index<br />
            WS.Range("B" &amp; iWriteToRow).Value = iLoop</p>
<p>        ElseIf IsWorksheet(WB.Sheets(iLoop).Name, WB) = True Then</p>
<p>            '/////////////////////////<br />
            '/// Sheet is a Worksheet<br />
            '/////////////////////////</p>
<p>            '/// Grab count<br />
            iWsCnt = iWsCnt + 1</p>
<p>            '/// Sheet is a regular worksheet<br />
            shtName = WB.Sheets(iLoop).Name<br />
            WS.Range("C" &amp; iWriteToRow).Hyperlinks.Add Anchor:=WS.Range("C" &amp; iWriteToRow), _<br />
                                                       Address:="#'" &amp; shtName &amp; "'!A1", _<br />
                                                       SubAddress:="#'" &amp; shtName &amp; "'!A1", _<br />
                                                       TextToDisplay:=shtName<br />
            WS.Range("C" &amp; iWriteToRow).HorizontalAlignment = xlLeft</p>
<p>            '/// Write number to TOC index<br />
            WS.Range("B" &amp; iWriteToRow).Value = iLoop</p>
<p>        Else</p>
<p>            '////////////////////////////////////<br />
            '/// Sheet is a dialog or macro sheet<br />
            '////////////////////////////////////</p>
<p>            '/// Grab count<br />
            '            iWsCnt = iWsCnt + 1</p>
<p>            '/// Get a total count of chart sheets, set variables<br />
            iOtherCnt = iOtherCnt + 1<br />
            shtName = WB.Sheets(iLoop).Name<br />
            WS.Range("C" &amp; iWriteToRow).Value = shtName<br />
            WS.Range("C" &amp; iWriteToRow).Font.ColorIndex = iShade</p>
<p>            '/// Get dimensions of write cell to apply button to it<br />
            iLeft = WS.Range("C" &amp; iWriteToRow).Left<br />
            iTop = WS.Range("C" &amp; iWriteToRow).Top<br />
            iWidth = WS.Range("C" &amp; iWriteToRow).Width<br />
            iHeight = WS.Range("C" &amp; iWriteToRow).RowHeight<br />
            sAddy = "R" &amp; iWriteToRow &amp; "C3"</p>
<p>            '/// Add the shape to the correct cell, add text to it and assign macro "GotoChart"<br />
            Set cb = WS.Shapes.AddShape(msoShapeRoundedRectangle, iLeft, iTop, iWidth, iHeight)<br />
            cb.Select<br />
            ExecuteExcel4Macro "FORMULA(""=" &amp; sAddy &amp; """)"<br />
            Selection.ShapeRange.TextFrame.VerticalAlignment = xlCenter<br />
            Selection.ShapeRange.TextFrame.HorizontalAlignment = xlLeft<br />
            Selection.ShapeRange.Fill.ForeColor.SchemeColor = 0<br />
            Selection.Font.Underline = xlUnderlineStyleSingle<br />
            Selection.Font.ColorIndex = 5<br />
            Selection.ShapeRange.Fill.Visible = msoFalse<br />
            Selection.ShapeRange.Line.Visible = msoFalse<br />
            Selection.OnAction = IIf(Len(sModuleRename) &gt; 0, sModuleRename, sModuleName) &amp; ".GotoOther"</p>
<p>            '/// Write number to TOC index<br />
            WS.Range("B" &amp; iWriteToRow).Value = iLoop</p>
<p>        End If</p>
<p>continueLoop:<br />
    Next iLoop</p>
<p>    '/// Set viewing options<br />
    Sheets(sSheetName).Range("C:C").EntireColumn.ColumnWidth = 30<br />
    Sheets(sSheetName).Range("A4").Activate</p>
<p>    '/// Add string to message prompt if there were any chart sheets added<br />
    If iChartCnt &gt; 0 Then<br />
        sMsg = DNL &amp; Space(13) &amp; iChartCnt &amp; " Chart sheets have been added"<br />
    End If</p>
<p>    '/// Add string to message prompt if there were any dialog or macro sheets added<br />
    If iOtherCnt &gt; 0 Then<br />
        sMsg = sMsg &amp; DNL &amp; Space(13) &amp; iOtherCnt<br />
        sMsg = sMsg &amp; " Other sheet" &amp; IIf(iOtherCnt &gt; 1, "s have", " has") &amp; " been added (i.e. Dialog &amp; Macro sheets)"<br />
    End If</p>
<p>    '/// Append string to message prompt for how many worksheets were added<br />
    sMsg = sMsg &amp; DNL &amp; Space(13) &amp; iWsCnt &amp; " Worksheets have been added"</p>
<p>    '/// If module name was changed, add that in the message prompt text<br />
    If bModuleName = True Then<br />
        MsgBox "Complete!" &amp; vbNewLine &amp; "The code module name was changed." &amp; sMsg, vbInformation, "Complete!"<br />
    Else<br />
        MsgBox "Complete!" &amp; sMsg, vbInformation, "Complete!"<br />
    End If</p>
<p>ExitEarly:<br />
    '/// Reset application settings back to default<br />
    Call TOGGLEEVENTS(True)</p>
<p>End Sub</p>
<p>'/// ***************************************************************************************<br />
'/// SUPPORTIVE FUNCTIONS<br />
'/// ***************************************************************************************</p>
<p>Public Sub TOGGLEEVENTS(blnState As Boolean)<br />
    '---------------------------------------------------------------------------------------<br />
    ' Procedure : TOGGLEEVENTS<br />
    ' Author    : Zack Barresse<br />
    ' Date      : 1/27/2012<br />
    ' Purpose   : Quickly toggle application Properties instead of calling them in each procedure<br />
    ' Variables : blnState - pass a true/false value indicated the property state desired<br />
    '---------------------------------------------------------------------------------------<br />
    If Not blnState Then Application.Calculation = xlCalculationManual<br />
    Application.DisplayAlerts = blnState<br />
    Application.EnableEvents = blnState<br />
    Application.ScreenUpdating = blnState<br />
    If blnState Then Application.CutCopyMode = False<br />
    If blnState Then Application.StatusBar = False<br />
    If blnState Then Application.Calculation = xlCalculationAutomatic<br />
End Sub</p>
<p>Public Function WSEXISTS(wksName As String, Optional WKB As Workbook) As Boolean<br />
    '---------------------------------------------------------------------------------------<br />
    ' Procedure : WSEXISTS<br />
    ' Author    : Zack Barresse<br />
    ' Date      : 1/27/2012<br />
    ' Purpose   : To test whether a worksheet exists in a workbook or not<br />
    ' Variables : wksName - pass a string name for a sheet to test for<br />
    '             WKB - optionally pass a workbook to test the sheet in, if not specified<br />
    '             the active workbook will be used<br />
    '---------------------------------------------------------------------------------------<br />
    If WKB Is Nothing Then<br />
        If ActiveWorkbook Is Nothing Then Exit Function<br />
        Set WKB = ActiveWorkbook<br />
    End If<br />
    On Error Resume Next<br />
    WSEXISTS = CBool(WKB.Sheets(wksName).Name &lt;&gt; "")<br />
    On Error GoTo 0<br />
End Function</p>
<p>Public Function IsWorksheet(shNameTemp As String, Optional WKB As Workbook) As Boolean<br />
    '---------------------------------------------------------------------------------------<br />
    ' Procedure : IsWorksheet<br />
    ' Author    : Zack Barresse<br />
    ' Date      : 1/27/2012<br />
    ' Purpose   : To discern whether or not a sheet in a given workbook is an actual<br />
    '             worksheet, as opposed to a macro, dialog or chart sheet.<br />
    ' Variables : shNameTemp - pass a string name for a sheet to test for<br />
    '             WKB - optionally pass a workbook to test the sheet in, if not specified<br />
    '             the active workbook will be used<br />
    '---------------------------------------------------------------------------------------<br />
    Dim wksTemp                 As Worksheet<br />
    If WKB Is Nothing Then<br />
        If ActiveWorkbook Is Nothing Then Exit Function<br />
        Set WKB = ActiveWorkbook<br />
    End If<br />
    On Error GoTo ErrFound<br />
    '/// Macro and Dialog sheets will throw an error in one of the next two lines<br />
    Set wksTemp = WKB.Sheets(shNameTemp)<br />
    If wksTemp.Name = wksTemp.CodeName Then<br />
        IsWorksheet = TypeName(WKB.Sheets(shNameTemp)) = "Worksheet"<br />
    End If<br />
ErrFound:<br />
    On Error GoTo 0<br />
End Function</p>
<p>Public Function IsChart(chtName As String) As Boolean<br />
    '---------------------------------------------------------------------------------------<br />
    ' Procedure : IsChart<br />
    ' Author    : Zack Barresse<br />
    ' Updated   : 1/27/2012<br />
    ' Purpose   : Check if the name passed is a Chart sheet or not<br />
    '---------------------------------------------------------------------------------------<br />
    On Error Resume Next<br />
    IsChart = CBool(ActiveWorkbook.Charts(chtName).Name &lt;&gt; "")<br />
    On Error GoTo 0<br />
End Function</p>
<p>Private Sub GotoOther()<br />
    '---------------------------------------------------------------------------------------<br />
    ' Procedure : GotoOther<br />
    ' Author    : Zack Barresse<br />
    ' Date      : 1/27/2012<br />
    ' Purpose   : Attached to a shape to allow for hyperlinking to other sheets<br />
    '---------------------------------------------------------------------------------------<br />
    Dim obj                     As Shape<br />
    Dim objName                 As String<br />
    On Error Resume Next<br />
    Set obj = ActiveSheet.Shapes(Application.Caller)<br />
    objName = obj.TopLeftCell.Value<br />
    ActiveWorkbook.Sheets(objName).Activate<br />
    On Error GoTo 0<br />
End Sub</p>
<p>Sub ChangeModuleName()<br />
    '---------------------------------------------------------------------------------------<br />
    ' Procedure : ChangeModuleName<br />
    ' Author    : Simon Lloyd<br />
    ' Date      : 4/20/2011<br />
    ' Purpose   : Check if a code module name already exists, if not, create it<br />
    '---------------------------------------------------------------------------------------<br />
    Dim vbModule                As VBIDE.VBComponent<br />
    bModuleName = False<br />
    If VBComponentExists(sModuleName, ThisWorkbook.VBProject) = False Then<br />
        Call fxModuleNameChange(sModuleName, ThisWorkbook)<br />
        bModuleName = True<br />
    End If<br />
End Sub</p>
<p>Public Sub fxModuleNameChange(newMacro As String, Optional WB As Workbook)<br />
    '---------------------------------------------------------------------------------------<br />
    ' Procedure : fxModuleNameChange<br />
    ' Author    : Simon Lloyd<br />
    ' Date      : 4/20/2011<br />
    ' Purpose   : Change a module name<br />
    ' Variables : newMacro - pass a string name for a module name to change to<br />
    '           : WB - optionally pass a workbook to look in<br />
    '---------------------------------------------------------------------------------------<br />
    Dim VBC As VBIDE.VBComponent, modCode As String<br />
    If WB Is Nothing Then Set WB = ThisWorkbook<br />
    For Each VBC In WB.VBProject.VBComponents<br />
        If VBC.CodeModule.CountOfLines &gt; 0 Then<br />
            modCode = VBC.CodeModule.Lines(1, VBC.CodeModule.CountOfLines)<br />
            If InStr(1, modCode, newMacro, vbTextCompare) &gt; 0 Then<br />
                VBC.Name = sModuleName<br />
                Exit For<br />
            End If<br />
        End If<br />
    Next VBC<br />
End Sub</p>
<p>Public Function VBComponentExists(VBCompName As String, Optional VBProj As VBIDE.VBProject = Nothing) As Boolean<br />
    '---------------------------------------------------------------------------------------<br />
    ' Procedure : VBComponentExists<br />
    ' Author    : Simon Lloyd<br />
    ' Date      : 4/20/2011<br />
    ' Purpose   : Check to see if a code module already exists.  If it does, and if the name<br />
    '             is not equal to the current module name (which will result in shape<br />
    '             hyperlinks being broken) then set the sModuleRename variable to the<br />
    '             current module name<br />
    ' Variables : VBCompName - pass a string name to check if it exists<br />
    '           : VBProj - otionally pass a specific project (workbook) to look in<br />
    '---------------------------------------------------------------------------------------<br />
    Dim VBP                     As VBIDE.VBProject<br />
    If VBProj Is Nothing Then<br />
        Set VBP = ActiveWorkbook.VBProject<br />
    Else<br />
        Set VBP = VBProj<br />
    End If<br />
    On Error Resume Next<br />
    sModuleRename = vbNullString<br />
    VBComponentExists = CBool(Len(VBP.VBComponents(VBCompName).Name))<br />
    If VBComponentExists And VBCompName &lt;&gt; VBP.VBE.ActiveCodePane.CodeModule Then<br />
        sModuleRename = VBP.VBE.ActiveCodePane.CodeModule<br />
    End If<br />
End Function</code></p>
<p>Copy, paste, run <em>CreateTOC</em>.  Done.  <img src='http://www.smittypro.com/Blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>NB: There is a link in the comments section of the code created from ShortURL.com, to which the full link is:<br />
<a href="http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/A_3515-Excel-VBA-to-create-a-Table-of-Contents-TOC-summary-sheet.html">http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/A_3515-Excel-VBA-to-create-a-Table-of-Contents-TOC-summary-sheet.html</a></p>
<p>This was code written by Dave Brett (brettdj) which is just as functional as this (unlike most other code out there to create a Table of Contents), but his differs from this functionally in that he used VBA to write code to the worksheet itself as an event, which is quite ingenious.</p>
<p>Many thanks to Simon Lloyd, Ken Puls, Anne Troy, Chip Pearson, for helping with pieces of code, testing, and inspiration.  <img src='http://www.smittypro.com/Blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/home/?status=Create+a+Table+of+Contents+in+Excel+http%3A%2F%2Fis.gd%2FgKI7A4" title="Post to Twitter"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter-micro3.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.facebook.com/share.php?u=http://www.smittypro.com/Blog/?p=409&amp;t=Create+a+Table+of+Contents+in+Excel" title="Post to Facebook"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/facebook/tt-facebook-micro3.png" alt="Post to Facebook" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.google.com/buzz/post?url=http://www.smittypro.com/Blog/?p=409&amp;imageurl=" title="Post to Google Buzz"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/gbuzz/tt-gbuzz-micro3.png" alt="Post to Google Buzz" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.smittypro.com/Blog/?p=409&amp;title=Create+a+Table+of+Contents+in+Excel&amp;summary=There+has+always+been+a+need+for+a+good+Table+of+Contents+in+Excel.++While+Word+features+this+natively+with+its+built-in+Styles%2C+unfortunately%2C+Exc...&amp;source=SmittyPro" title="Post to LinkedIn"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/linkedin/tt-linkedin-micro3.png" alt="Post to LinkedIn" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://technorati.com/faves?add=http://www.smittypro.com/Blog/?p=409" title="Post to Technorati"><img class="nothumb" src="http://www.smittypro.com/Blog/wp-content/plugins/tweet-this/icons/en/technorati/tt-technorati-micro3.png" alt="Post to Technorati" /></a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.smittypro.com/Blog/?feed=rss2&#038;p=409</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
