<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>frice's WebLog : Excel 2007</title><link>http://blogs.msdn.com/frice/archive/tags/Excel+2007/default.aspx</link><description>Tags: Excel 2007</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Excel's Worksheets and Sheets Collection - What's the Difference?</title><link>http://blogs.msdn.com/frice/archive/2007/12/05/excel-s-worksheets-and-sheets-collection-what-s-the-difference.aspx</link><pubDate>Wed, 05 Dec 2007 19:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6667988</guid><dc:creator>frice</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/frice/comments/6667988.aspx</comments><wfw:commentRss>http://blogs.msdn.com/frice/commentrss.aspx?PostID=6667988</wfw:commentRss><description>&lt;P&gt;Among the top four objects most searched for on the Microsoft Developer Network by Excel programmers are the &lt;STRONG&gt;Sheets&lt;/STRONG&gt; collection and the &lt;STRONG&gt;Worksheets&lt;/STRONG&gt; collection (the other two are the &lt;STRONG&gt;Range&lt;/STRONG&gt; object and the &lt;STRONG&gt;Application&lt;/STRONG&gt; object). As an aside, I've written&amp;nbsp;new articles on programming the &lt;STRONG&gt;Range&lt;/STRONG&gt; and &lt;STRONG&gt;Application&lt;/STRONG&gt; objects which will be published on the Office Developer Center in January 2008.&lt;/P&gt;
&lt;P&gt;For new Excel programmers, there might be some confusion as to the difference between the &lt;STRONG&gt;Sheets&lt;/STRONG&gt; and &lt;STRONG&gt;Worksheets&lt;/STRONG&gt; collections. The &lt;STRONG&gt;Worksheets&lt;/STRONG&gt; collection contains the items you typically think of on an Excel worksheet: rows, columns, cells, and formulas. The &lt;STRONG&gt;Sheets&lt;/STRONG&gt; collection, on the other hand, consist of not only a collection of worksheets but also other types of sheets to include Chart sheets, Excel 4.0 macro sheets (also known as XLM files) and Excel 5.0 dialog sheets (allows you to create custom dialog boxes). Chart sheets are charts that take up an entire worksheet, but not charts that are inserted as part of a worksheet. The Excel 4 and Excel 5 sheets are legacy items used to maintain backwards compatibility and ease the transition from older versions of Excel to new. And just to further muddy the waters, there is also a &lt;STRONG&gt;Charts&lt;/STRONG&gt; collection that is made up of chart sheets.&lt;/P&gt;
&lt;P&gt;The &lt;STRONG&gt;Count&lt;/STRONG&gt; property of the &lt;STRONG&gt;Worksheets&lt;/STRONG&gt; collection contains the number of worksheets in a workbook. The &lt;STRONG&gt;Count&lt;/STRONG&gt; property of the &lt;STRONG&gt;Sheets&lt;/STRONG&gt; collection contains the number of all sheets in a workbook to include chart sheets and worksheets. For example, you can add a specific number of worksheets to a workbook with the following:&lt;/P&gt;
&lt;P&gt;Do While Worksheets.Count &amp;lt; 5&lt;BR&gt;&amp;nbsp;&amp;nbsp; ThisWorkbook.Sheets.Add&lt;BR&gt;Loop&lt;/P&gt;
&lt;P&gt;The worksheets you add may then become either a chart sheet or left as a worksheet, at which time, they become part of the &lt;STRONG&gt;Charts&lt;/STRONG&gt; or &lt;STRONG&gt;Worksheets&lt;/STRONG&gt; collection, respectively, or collectively become members of the &lt;STRONG&gt;Sheets&lt;/STRONG&gt; collection. In the following example, you change the name of the last sheet in a workbook:&lt;/P&gt;
&lt;P&gt;Dim wrkSheetName As String&lt;BR&gt;wrkSheetName = "Projected Sales Chart"&lt;BR&gt;Sheets(Sheets.Count).Name = wrkSheetName&lt;/P&gt;
&lt;P&gt;Note that because you are using the &lt;STRONG&gt;Sheets&lt;/STRONG&gt; collection, the last sheet in this workbook could be either a worksheet or a chart sheet. Given the name, it is likely a chart sheet.&lt;/P&gt;
&lt;P&gt;As you might expect, the &lt;STRONG&gt;Sheets&lt;/STRONG&gt; collection contains more methods than the &lt;STRONG&gt;Worksheets&lt;/STRONG&gt; collection since it is home to more types of sheets. However, in both collections, there are a variety of methods to do such things as add, delete, copy, and move a sheet. There is ample documentation on these and other properties,&amp;nbsp;methods, and events&amp;nbsp;of the &lt;STRONG&gt;Worksheets&lt;/STRONG&gt; and &lt;STRONG&gt;Sheets&lt;/STRONG&gt; collections from the Excel portal on Office Developer Center on MSDN (&lt;A class="" href="http://msdn.microsoft.com/office" mce_href="http://msdn.microsoft.com/office"&gt;http://msdn.microsoft.com/office&lt;/A&gt;).&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6667988" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/frice/archive/tags/Excel+2007/default.aspx">Excel 2007</category><category domain="http://blogs.msdn.com/frice/archive/tags/Worksheets+collection/default.aspx">Worksheets collection</category><category domain="http://blogs.msdn.com/frice/archive/tags/Sheets+collection/default.aspx">Sheets collection</category></item></channel></rss>