<?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>Bacon Bits: &#187; Formulas</title>
	<atom:link href="http://datapigtechnologies.com/blog/index.php/tag/formulas/feed/" rel="self" type="application/rss+xml" />
	<link>http://datapigtechnologies.com/blog</link>
	<description>A DataPig Technologies Blog</description>
	<lastBuildDate>Fri, 30 Jul 2010 08:06:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sort by Color in Excel 2003</title>
		<link>http://datapigtechnologies.com/blog/index.php/sort-by-color-in-excel-2003/</link>
		<comments>http://datapigtechnologies.com/blog/index.php/sort-by-color-in-excel-2003/#comments</comments>
		<pubDate>Tue, 18 May 2010 09:05:43 +0000</pubDate>
		<dc:creator>datapig</dc:creator>
				<category><![CDATA[Excel Formulas]]></category>
		<category><![CDATA[Excel Tips and Tricks]]></category>
		<category><![CDATA[Excel VBA]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Formulas]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://datapigtechnologies.com/blog/index.php/sort-by-color-in-excel-2003/</guid>
		<description><![CDATA[Every now and then, you encounter a table where color is supposed to mean something. In this table, each color represents a certain attribute (red = below target, yellow = in danger). If you're thinking that tagging records with a color is stupid, I agree. But we live in a world full of goofballs that [...]]]></description>
			<content:encoded><![CDATA[<p>Every now and then, you encounter a table where color is supposed to mean something. In this table, each color represents a certain attribute (red = below target, yellow = in danger). If you're thinking that tagging records with a color is stupid, I agree. But we live in a world full of goofballs that think it's clever to do things like this.</p>
<p> <span id="more-1992"></span></p>
<p>The problem here is that tagging records with just a color makes it difficult to find and consolidate the like-colors (especially in Excel 2003 where, unlike Excel 2007, there are no built-in tools that allow you to easily sort by color).</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/05/051810_0905_SortbyColor1.png" alt="" /></p>
<p> </p>
<p>But with a little VBA, there is a way to sort by color in Excel 2003.</p>
<p> </p>
<p><span style="font-size:12pt"><strong>Step 1 – Create Your Custom Functions<br />
</strong></span></p>
<ul>
<li>Press Alt-F11 on your keyboard to get to the Visual Basic Editor.</li>
<li>Go to the menu and select Insert -&gt; Module.</li>
<li>Paste this bit of code into the empty module.</li>
</ul>
<p><strong><em>Function GetBackgroundColor(MyRange As Range)<br />
GetBackgroundColor = MyRange.Interior.ColorIndex<br />
End Function<br />
</em></strong></p>
<p><strong><em>Function GetFontColor(MyRange As Range)<br />
GetFontColor = MyRange.Font.ColorIndex<br />
End Function<br />
</em></strong></p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/05/051810_0905_SortbyColor2.png" alt="" /><strong><em><br />
</em></strong></p>
<p> </p>
<p> </p>
<p><span style="font-size:12pt"><br />
<strong>Step 2 – Apply your Custom functions<br />
</strong></span></p>
<ul>
<li>Create a new column and call it Color Index</li>
<li>In your new column, enter the Get Color function needed. In this case, I need to get the color index for the cell background color, so I will use the GetBackgroundColor function.</li>
</ul>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/05/051810_0905_SortbyColor3.png" alt="" /></p>
<p> </p>
<p> </p>
<p><span style="font-size:12pt"><strong>Step 3 – Sort by the Color Index Column<br />
</strong></span></p>
<ul>
<li>Sort your data table by the newly created Color Index column.</li>
</ul>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/05/051810_0905_SortbyColor4.png" alt="" /></p>
<p> </p>
<p> </p>
<p>There you have it – Sorting by color in Excel 2003.  As I mentioned before, Excel 2007 has a better (built-in) solution. To learn how to sort by color in Excel 2007, check out <a href="http://blog.contextures.com/archives/2010/02/24/sort-by-colour-in-excel/" target="_blank">Debra's Post</a>.</p>
<p> </p>
<p>I'd like to think that not many of you will need this Excel 2003 tip, but I know that some companies will keep you their folks on Excel 2003 for another 2-3 years.</p>
]]></content:encoded>
			<wfw:commentRss>http://datapigtechnologies.com/blog/index.php/sort-by-color-in-excel-2003/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Highlight Named Ranges Part 2</title>
		<link>http://datapigtechnologies.com/blog/index.php/highlight-named-ranges-part-2/</link>
		<comments>http://datapigtechnologies.com/blog/index.php/highlight-named-ranges-part-2/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 10:08:43 +0000</pubDate>
		<dc:creator>datapig</dc:creator>
				<category><![CDATA[Excel Formulas]]></category>
		<category><![CDATA[Excel VBA]]></category>
		<category><![CDATA[Spreadsheet Auditing]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Formulas]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://datapigtechnologies.com/blog/index.php/highlight-named-ranges-part-2/</guid>
		<description><![CDATA[Last week, I posted 'Highlight All Named Ranges Part 1', where I shared a macro that will literally color all the cells that belong to any Named Range yellow.
This allows you to get a visual indication of how many Named Ranges exist and where they are.
 
For example, in this screenshot I've run my highlight ranges [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, I posted '<a href="http://datapigtechnologies.com/blog/index.php/highlight-all-named-ranges-part-1/" target="_blank">Highlight All Named Ranges Part 1'</a>, where I shared a macro that will literally color all the cells that belong to any Named Range yellow.</p>
<p>This allows you to get a visual indication of how many Named Ranges exist and where they are.</p>
<p> <span id="more-1894"></span></p>
<p>For example, in this screenshot I've run my highlight ranges code. You can see there are four Named Ranges here.</p>
<p>This is pretty cool, but now I'd like to figure out exactly which Named Range each cell belongs to?</p>
<p>That is to say, I can now see that cell F3 belongs to a Named Range, but how do I figure out which range it belongs to?</p>
<p>Ideally, I'd like to double-click on Cell F3 and see the name of the Named Range.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/04/040610_1007_HighlightNa1.png" alt="" /></p>
<p> </p>
<p> </p>
<p>This is where this brilliant piece of code comes in. This procedure will check the range of the double-clicked cell to see if it intersects with any of the existing Named Ranges. Then it returns an answer in the form of a message box.</p>
<div class="syntax_hilite">
<div id="vb-2">
<div class="vb"><span style="color: #b1b100;">Dim</span> oName <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Name</span><br />
<span style="color: #b1b100;">Dim</span> sList <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></p>
<p><span style="color: #808080;">'Check the active cell against each Named Range</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">For</span> Each oName In ActiveWorkbook.<span style="color: #66cc66;">Names</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #808080;">'If the active cell intersects with a Named Range, capture the Name</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">If</span> <span style="color: #b1b100;">Not</span> Intersect<span style="color:#006600; font-weight:bold;">&#40;</span>ActiveCell, Range<span style="color:#006600; font-weight:bold;">&#40;</span>oName.<span style="color: #66cc66;">RefersTo</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> Is <span style="color: #b1b100;">Nothing</span> <span style="color: #b1b100;">Then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">If</span> sList = <span style="color: #ff0000;">""</span> <span style="color: #b1b100;">Then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sList = oName.<span style="color: #b1b100;">Name</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">Else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sList = sList &amp; <span style="color: #b1b100;">vbCrLf</span> &amp; oName.<span style="color: #b1b100;">Name</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">Next</span> oName<br />
&nbsp; &nbsp; <br />
<span style="color: #808080;">'Create a message if no Named Ranges were found</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">If</span> sList = <span style="color: #ff0000;">""</span> <span style="color: #b1b100;">Then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">MsgBox</span> <span style="color: #ff0000;">"This cell is not referenced in any Named Ranges"</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">Else</span><br />
<span style="color: #808080;">'If Named Ranges were found, show them in a message</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">MsgBox</span> sList, <span style="color: #b1b100;">vbOKOnly</span>, <span style="color: #ff0000;">"Referenced in: "</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span></div>
</div>
</div>
<p>
 </p>
<p>To implement this as a double-click, simply paste the code into the BeforeDoubleClick event of the target worksheet.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/04/040610_1007_HighlightNa2.png" alt="" /></p>
<p> </p>
<p> </p>
<p>With this code in place, I can now double click on Cell F3 and see exactly which Named Range It belongs to.</p>
<p>In this case, it looks like F3 belongs to the Data2009 Named Range.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/04/040610_1007_HighlightNa3.png" alt="" /></p>
<p> </p>
<p> </p>
<p>If the active cell belongs to several named ranges, then they will all be listed.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/04/040610_1007_HighlightNa4.png" alt="" /></p>
<p> </p>
<p> </p>
<p>So this piece of code, coupled with the code in '<a href="http://datapigtechnologies.com/blog/index.php/highlight-all-named-ranges-part-1/" target="_blank">Highlight All Named Ranges Part 1'</a> makes for a pretty handy spreadsheet auditing combo.</p>
<p> </p>
<p>Ok then – I gotta run. It's 5am here, and the kids are still sleeping. It's time to steal more candy from their Easter Baskets.</p>
]]></content:encoded>
			<wfw:commentRss>http://datapigtechnologies.com/blog/index.php/highlight-named-ranges-part-2/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Highlight All Named Ranges Part 1</title>
		<link>http://datapigtechnologies.com/blog/index.php/highlight-all-named-ranges-part-1/</link>
		<comments>http://datapigtechnologies.com/blog/index.php/highlight-all-named-ranges-part-1/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 14:47:42 +0000</pubDate>
		<dc:creator>datapig</dc:creator>
				<category><![CDATA[Excel Formulas]]></category>
		<category><![CDATA[Spreadsheet Auditing]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Formulas]]></category>

		<guid isPermaLink="false">http://datapigtechnologies.com/blog/?p=1864</guid>
		<description><![CDATA[If you spend your time auditing other people's worksheets, you'll know that Excel users love their named ranges. I've run across some spreadsheets where 50 or more individual cells are given individual names. This makes auditing a spreadsheet an extremely muddy experience.
It sometimes helps to know where the named ranges are.

.
Here is a macro I [...]]]></description>
			<content:encoded><![CDATA[<p>If you spend your time auditing other people's worksheets, you'll know that Excel users love their named ranges. I've run across some spreadsheets where 50 or more individual cells are given individual names. This makes auditing a spreadsheet an extremely muddy experience.</p>
<p>It sometimes helps to know where the named ranges are.<br />
<span id="more-1864"></span><br />
<span style="color: #ffffff;">.</span></p>
<p>Here is a macro I use to highlight all the named ranges in a workbook yellow.</p>
<p>Just copy and paste this code in a new Standard Module. Once you have it in, you can fire this macro to turn all the cells that belong to a named range Yellow.</p>
<div class="syntax_hilite">
<div id="vb-4">
<div class="vb"><span style="color: #b1b100;">Sub</span> HighlightRanges<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color: #b1b100;">Dim</span> RangeName <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Name</span><br />
<span style="color: #b1b100;">Dim</span> HighlightRange <span style="color: #b1b100;">As</span> Range</p>
<p><span style="color: #b1b100;">On</span> <span style="color: #b1b100;">Error</span> <span style="color: #b1b100;">Resume</span> <span style="color: #b1b100;">Next</span><br />
<span style="color: #b1b100;">For</span> Each RangeName In ActiveWorkbook.<span style="color: #66cc66;">Names</span><br />
<span style="color: #b1b100;">Set</span> HighlightRange = RangeName.<span style="color: #66cc66;">RefersToRange</span><br />
HighlightRange.<span style="color: #66cc66;">Interior</span>.<span style="color: #66cc66;">ColorIndex</span> = <span style="color: #cc66cc;">36</span><br />
<span style="color: #b1b100;">Next</span> RangeName</p>
<p><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span></div>
</div>
</div>
<p></p>
<p><span style="color: #ffffff;">.</span></p>
<p>As a bonus, this tip also gives you a visual indication of the level of anal retentiveness your co-workers achieve.</p>
<p>Next week, I'll give you a way to indicate to which Named range each highlighted cell belongs.</p>
]]></content:encoded>
			<wfw:commentRss>http://datapigtechnologies.com/blog/index.php/highlight-all-named-ranges-part-1/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Formula Auditing Art</title>
		<link>http://datapigtechnologies.com/blog/index.php/formula-auditing-art/</link>
		<comments>http://datapigtechnologies.com/blog/index.php/formula-auditing-art/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 01:52:23 +0000</pubDate>
		<dc:creator>datapig</dc:creator>
				<category><![CDATA[Excel Tips and Tricks]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Formulas]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://datapigtechnologies.com/blog/index.php/formula-auditing-art/</guid>
		<description><![CDATA[I was auditing a spreadsheet the other day and I noticed that when I used the formula auditing tools to trace dependents, a pattern came up that looked like a dog. I know…too much silly juice for me.
So anyway, I thought it would be cool to purposely write formulas so when you applied formula auditing, [...]]]></description>
			<content:encoded><![CDATA[<p>I was auditing a spreadsheet the other day and I noticed that when I used the formula auditing tools to trace dependents, a pattern came up that looked like a dog. I know…too much silly juice for me.</p>
<p>So anyway, I thought it would be cool to purposely write formulas so when you applied formula auditing, it made a picture.</p>
<p>Like this:<br />
<span id="more-1863"></span></p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/03/033110_0151_FormulaAudi1.png" alt="" /></p>
<p> </p>
<p>This is an easy one. First write these formulas.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/03/033110_0151_FormulaAudi2.png" alt="" /></p>
<p> </p>
<p>Then place your cursor in cell H10 and select Trace Precedents under the Formulas tab. This will cause Excel to draw arrows from all the cells that feed the formula in cell H10.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/03/033110_0151_FormulaAudi3.png" alt="" /></p>
<p> </p>
<p>Like so:</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/03/033110_0151_FormulaAudi4.png" alt="" /></p>
<p> </p>
<p>Do the same for the rest of the formulas. And you have your picture.</p>
<p> </p>
<p>Here, I've copied and pasted a few times, took away the gridlines, and made the values white.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/03/033110_0151_FormulaAudi5.png" alt="" /></p>
<p> </p>
<p> </p>
<p>Here's an April fool's challenge.</p>
<p>Take your best shot at creating your own formula auditing art. Share your entry via a link in the comments field.</p>
<p>The coolest entry will win this book:</p>
<p><a href="http://www.amazon.com/Excel-Analysts-Guide-Access/dp/0470567015/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1268198951&amp;sr=1-1"><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/03/033110_0151_FormulaAudi6.jpg" border="0" alt="" /></a></p>
<p> </p>
<p><strong>Here's a tip:</strong> Draw out a frame of your picture first using lines and arrows. Then use your frame to build out your formulas. Once your formulas are built, delete your frame and apply the formula auditing.</p>
]]></content:encoded>
			<wfw:commentRss>http://datapigtechnologies.com/blog/index.php/formula-auditing-art/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Getting Data from Previous Sheet</title>
		<link>http://datapigtechnologies.com/blog/index.php/getting-data-from-previous-sheet/</link>
		<comments>http://datapigtechnologies.com/blog/index.php/getting-data-from-previous-sheet/#comments</comments>
		<pubDate>Mon, 29 Mar 2010 07:09:27 +0000</pubDate>
		<dc:creator>datapig</dc:creator>
				<category><![CDATA[Excel Formulas]]></category>
		<category><![CDATA[Excel VBA]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Formulas]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://datapigtechnologies.com/blog/?p=1847</guid>
		<description><![CDATA[About a week ago, a client of mine asked me if I could write him a function to pull data from the previous worksheet. Upon further interrogation, I found out that he has a workbook where he manages his monthly budget. Each tab consists of a month's data. The first tab is named January, the [...]]]></description>
			<content:encoded><![CDATA[<p>About a week ago, a client of mine asked me if I could write him a function to pull data from the previous worksheet. Upon further interrogation, I found out that he has a workbook where he manages his monthly budget. Each tab consists of a month's data. The first tab is named January, the second tab is named February, etc. </p>
<p>What he needed was a function that would pull data from the previous month's sheet without having to specify the sheet name. Why? Because at the end of each month, he would add another sheet and he did want to re-jigger his formulas to change sheet names.</p>
<p> <span id="more-1847"></span></p>
<p>I could have suggested a database format, but he's pretty happy with his budget sheet. Plus, he's a pretty important client so I complied with his request and put together this function. You may be able to adapt it if needed.</p>
<p> </p>
<div class="syntax_hilite">
<div id="vb-6">
<div class="vb"><span style="color: #b1b100;">Function</span> PrevSheet<span style="color:#006600; font-weight:bold;">&#40;</span>TargetCell <span style="color: #b1b100;">As</span> Range<span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color: #b1b100;">Dim</span> SheetIndex <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span></p>
<p><span style="color: #808080;">'Make sure the formula calculates even if moving sheets around</span><br />
&nbsp; &nbsp; Application.<span style="color: #66cc66;">Volatile</span></p>
<p><span style="color: #808080;">'Get the index of sheet where the caller formula resides</span><br />
&nbsp; &nbsp; SheetIndex = Application.<span style="color: #66cc66;">Caller</span>.<span style="color: #66cc66;">Parent</span>.<span style="color: #66cc66;">Index</span></p>
<p><span style="color: #808080;">'Let user know if the caller is on the first sheet</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">If</span> SheetIndex = <span style="color: #cc66cc;">1</span> <span style="color: #b1b100;">Then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; PrevSheet = <span style="color: #ff0000;">"No Previous Sheet"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">Exit</span> <span style="color: #b1b100;">Function</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span></p>
<p><span style="color: #808080;">'Return the target cell value in the previous workhseet</span><br />
&nbsp; &nbsp; PrevSheet = Sheets<span style="color:#006600; font-weight:bold;">&#40;</span>SheetIndex - <span style="color: #cc66cc;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Range</span><span style="color:#006600; font-weight:bold;">&#40;</span>TargetCell.<span style="color: #66cc66;">Address</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span></p>
<p><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Function</span></div>
</div>
</div>
<p></p>
<p> </p>
<p>With this function, you can enter a formula like <strong>=PrevSheet(A1) </strong>to get the value in cell A1 from the previous sheet - no matter what the sheet name is.<br />
<br /></br></p>
<p>After I gave him my function, I found a better function on Walkenbach's site.</p>
<p><a href="http://spreadsheetpage.com/index.php/tip/a_custom_function_for_relative_sheet_references/" target="_blank">Walkenbach's function</a> allows a bit more flexibility in that you can point to any sheet simply by resetting the offset number.</p>
<p>It’s amazing how many ways there are to accomplish any given tasks using VBA.</p>
]]></content:encoded>
			<wfw:commentRss>http://datapigtechnologies.com/blog/index.php/getting-data-from-previous-sheet/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Why FIND when you can SEARCH</title>
		<link>http://datapigtechnologies.com/blog/index.php/why-find-when-you-can-search/</link>
		<comments>http://datapigtechnologies.com/blog/index.php/why-find-when-you-can-search/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 10:25:25 +0000</pubDate>
		<dc:creator>datapig</dc:creator>
				<category><![CDATA[Excel Formulas]]></category>
		<category><![CDATA[Excel Tips and Tricks]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Formulas]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://datapigtechnologies.com/blog/?p=1817</guid>
		<description><![CDATA[Vinicius writes to ask:
"Dear Mr. Pig. I would like to know what the difference is between Excel's FIND and SEARCH. Which one should I use?"

I love the respect Vinicius shows by calling me Mr. Pig. Anyway, here is your answer Mr. Vinicius:
 
There are two differences between Excel's SEARCH and FIND functions.
 
First, the FIND function is [...]]]></description>
			<content:encoded><![CDATA[<p>Vinicius writes to ask:</p>
<p><em>"Dear Mr. Pig. I would like to know what the difference is between Excel's FIND and SEARCH. Which one should I use?"<br />
</em></p>
<p>I love the respect Vinicius shows by calling me Mr. Pig. Anyway, here is your answer Mr. Vinicius:</p>
<p> </p>
<p>There are two differences between Excel's SEARCH and FIND functions.</p>
<p> <span id="more-1817"></span></p>
<p>First, the FIND function is case sensitive, while the SEARCH function is not.</p>
<p>As you can see in this example, the formula in D2 returns 13 because the FIND function is looking for the first Capital B. The first capital B just happens to be the 13<sup>th</sup> character.</p>
<p>The formula in cell D3 is using the SEARCH function. That function isn't case sensitivity, so it returns the first B it finds (character number 3).</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/03/031510_1024_WhyFINDwhen1.png" alt="" /></p>
<p> </p>
<p> </p>
<p>The Second difference between FIND and SEARCH is the ability to use Wildcard characters. The SEARCH function handles wildcard characters, while the FIND function does not.</p>
<p>In this example, I'm using the (?) wildcard character to tell the SEARCH function to find the first string that starts with a B and ends with a C. The first string that meets my criteria starts on character 13, so that's what I get.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/03/031510_1024_WhyFINDwhen2.png" alt="" /></p>
<p> </p>
<p><span style="font-size:12pt"><strong>Which one should you use?<br />
</strong></span></p>
<p>Technically, the SEARCH function is safer to use because you won't accidentally pull the wrong position due case sensitivity.</p>
<p>I don't think I've ever needed to do a case sensitive find. I'll never use the SEARCH function's wildcard ability, but it's nice that it's there.</p>
<p> </p>
<p>I'll be honest; prior to this blog post, I used the FIND function mainly out of habit. In fact, prior to Vinicius' email, I kind of forgot about the SEARCH function.</p>
<p>I'm going to make an effort to use the SEARCH function from now on. Well Vinicius, I guess I'm recommending the SEARCH function.</p>
]]></content:encoded>
			<wfw:commentRss>http://datapigtechnologies.com/blog/index.php/why-find-when-you-can-search/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Color is Not Data</title>
		<link>http://datapigtechnologies.com/blog/index.php/a-color-is-not-data/</link>
		<comments>http://datapigtechnologies.com/blog/index.php/a-color-is-not-data/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 05:06:31 +0000</pubDate>
		<dc:creator>datapig</dc:creator>
				<category><![CDATA[Excel Formulas]]></category>
		<category><![CDATA[Excel Tips and Tricks]]></category>
		<category><![CDATA[Excel VBA]]></category>
		<category><![CDATA[Visualizations]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Formulas]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[Visualization]]></category>

		<guid isPermaLink="false">http://datapigtechnologies.com/blog/?p=1769</guid>
		<description><![CDATA[Ok people. Repeat after me – "A color is not data".
Every so often I get a spreadsheet from someone who thinks that colors play a major role in data management. You know – those people who happily say "I tagged those records with Yellow". Oh really? I don't think my version of Excel has a "Yellow" [...]]]></description>
			<content:encoded><![CDATA[<p>Ok people. Repeat after me – "A color is not data".</p>
<p>Every so often I get a spreadsheet from someone who thinks that colors play a major role in data management. You know – those people who happily say "I tagged those records with Yellow". Oh really? I don't think my version of Excel has a "Yellow" data type.</p>
<p> <span id="more-1769"></span></p>
<p>Anyway, I recently got a dataset from a client who included this gem of a column. Isn't it pretty? Apparently, Gray means 'In Progress', Red means 'Past Due', and Green means 'Complete'. I guess the goal here was to save typing a status in a new column?</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/02/022510_0504_AColorisNot1.png" alt="" /></p>
<p> </p>
<p>In any event, my task was to get this monthly feed and load it into a SQL server database. So my first step was to create a User Defined Function that would allow me to identify the Font Color of a range through a color index. I entered this code into a standard Module:</p>
<p style="margin-left: 36pt"><strong><em>Function GetFontColor(MyRange As Range)<br />
</em></strong><strong><em>GetFontColor = MyRange.Font.ColorIndex<br />
</em></strong><strong><em>End Function<br />
</em></strong></p>
<p> </p>
<p>At this point, I could use my function to simply point to a cell and get the index number of the font color.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/02/022510_0504_AColorisNot2.png" alt="" /></p>
<p> </p>
<p>Once I identified the appropriate color-to-status mapping, I created a simple table that translated the color index into a status.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/02/022510_0504_AColorisNot3.png" alt="" /></p>
<p> </p>
<p>Finally, I wrapped my GetFontColor Function in a VLookup to get the Status name.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/02/022510_0504_AColorisNot4.png" alt="" /></p>
<p> </p>
<p>Tada! Now I have a way to easily extract the real data from this lame coloring system.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/02/022510_0504_AColorisNot5.png" alt="" /></p>
<p> </p>
<p>A couple of notes:</p>
<p>You can't use this to pull out the color index of any cell that gets its color from Conditional Formatting. This is because the FormatCondition object is not tied to the Range Object. I've seen some code to pull out conditional color, but it gets pretty nasty.</p>
<p> </p>
<p>If you want to pull out the background color index instead of the font color index use this:</p>
<p> <strong><em>Function GetFontColor(MyRange As Range)<br />
</em></strong><strong><em>GetFontColor = MyRange.</em></strong><strong><em>Interior.ColorIndex<br />
</em></strong><strong><em>End Function</em></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://datapigtechnologies.com/blog/index.php/a-color-is-not-data/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Excel Defunct Defaults</title>
		<link>http://datapigtechnologies.com/blog/index.php/excel-defunct-defaults/</link>
		<comments>http://datapigtechnologies.com/blog/index.php/excel-defunct-defaults/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 17:14:27 +0000</pubDate>
		<dc:creator>datapig</dc:creator>
				<category><![CDATA[Excel Formulas]]></category>
		<category><![CDATA[Annoyances]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Formulas]]></category>

		<guid isPermaLink="false">http://datapigtechnologies.com/blog/?p=1745</guid>
		<description><![CDATA[A week ago, Dick Kusleika posted an excellent article outlining some Formula Tips.  I've already made plans to steal and use his ideas in my training.  But my plagiaristic habits are not the reason for this post.
?
.

In the comments of Kusleika’s post, I astutely pointed out that:
     "When I use VLOOKUPS, I replace Range_Lookup argument “FALSE” [...]]]></description>
			<content:encoded><![CDATA[<p>A week ago, Dick Kusleika posted an excellent article outlining some <a href="http://www.dailydoseofexcel.com/archives/2010/02/10/formula-tips/" target="_blank">Formula Tips</a>.  I've already made plans to steal and use his ideas in my training.  But my plagiaristic habits are not the reason for this post.<br />
<span style="color: #ffffff;">?<br />
.</span><br />
<span id="more-1745"></span><br />
In the comments of Kusleika’s post, I astutely pointed out that:</p>
<p><em>     "When I use VLOOKUPS, I replace Range_Lookup argument “FALSE” with 0:<br />
       Instead of this: VLOOKUP(A1,Sheet2!A1:C100,3,FALSE)<br />
      I use this: VLOOKUP(A1,Sheet2!A1:C100,3,0)"<br />
<span style="color: #ffffff;">.</span></em></p>
<p>Throughout the course of the comment thread, it was agreed that the leaving off the FALSE or the <strong>0</strong> from a VLOOKUP formula would essentially default the Range_Lookup argument to True.<br />
<span style="color: #ffffff;">.</span></p>
<p>So if you entered this formula:  VLOOKUP(A1,Sheet2!A1:C100,3)<br />
It’s the same as this:  VLOOKUP(A1,Sheet2!A1:C100,3, TRUE)<br />
<span style="color: #ffffff;">.</span></p>
<p>Now, I’ve worked with Excel for a long time.  I can count on one hand the number of times I’ve had to use TRUE as the Range_Lookup argument in a VLOOKUP instead of FALSE.  I’m confident that this is the case for a majority of users out there.</p>
<p><span style="color: #ffffff;">.</span><br />
So why is the TRUE the default?  This is what I like to call a Defunct Default – a default that doesn’t jive with a majority of real world scenarios.<br />
<span style="color: #ffffff;">?<br />
.</span></p>
<p>Another example of a Defunct Default can be found in the MATCH function.<br />
When using a MATCH function, you need to indicate a Match_Type as the last argument.<br />
<span style="color: #ffffff;">.</span></p>
<p><strong>1 </strong>finds the largest value that is less than or equal to lookup_value<br />
<strong>-1 </strong>finds the smallest value that is greater than or equal to lookup_value<br />
<strong>0 </strong>finds the exact match.<br />
<span style="color: #ffffff;">.</span></p>
<p>If you  leave off the Match_Type Argument, a Match Type of <strong>1</strong> the default.<br />
<span style="color: #ffffff;">.</span></p>
<p>So if you enter this:  =MATCH(39,B2:B5)<br />
It’s the same as this: =MATCH(39,B2:B5, 1)</p>
<p><span style="color: #ffffff;">.</span></p>
<p>Unfortunately, the vast majority of the scenarios where I needed the MATCH function, I needed to match Text, where an exact match is required (Match Type 0).  With the default, matching any text would yield a result no matter what text I entered.  I need to be able to match only if the text exists in my lookup array.<br />
In terms of a real-world default, why wouldn’t an exact match be the logical choice?  How exactly did 1 trump -1 as the default anyway?<br />
<span style="color: #ffffff;">?<br />
.</span></p>
<p>I’m too lazy to think of more examples of defunct defaults.  Can you think of any?</p>
]]></content:encoded>
			<wfw:commentRss>http://datapigtechnologies.com/blog/index.php/excel-defunct-defaults/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Paste Special Skip Blanks</title>
		<link>http://datapigtechnologies.com/blog/index.php/paste-special-skip-blanks/</link>
		<comments>http://datapigtechnologies.com/blog/index.php/paste-special-skip-blanks/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 14:20:12 +0000</pubDate>
		<dc:creator>datapig</dc:creator>
				<category><![CDATA[Excel Tips and Tricks]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Formulas]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://datapigtechnologies.com/blog/index.php/paste-special-skip-blanks/</guid>
		<description><![CDATA[Today, I want to show you how to use the Skip Blanks option in the Paste Special dialog box. You've all probably seen it there, but you've never used it.
Here it is in the expertly placed square box.


 
I know why you've never used it. Skip blanks sounds dangerous. It sounds like you're entire spreadsheet will [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I want to show you how to use the Skip Blanks option in the Paste Special dialog box. You've all probably seen it there, but you've never used it.</p>
<p>Here it is in the expertly placed square box.</p>
<p><span id="more-1664"></span></p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/01/012810_1419_PasteSpecia1.png" alt="" /></p>
<p> </p>
<p>I know why you've never used it. Skip blanks sounds dangerous. It sounds like you're entire spreadsheet will shift to the left or some other nonsense. Nooooo thank you.</p>
<p>But I'm here to say, it's actually a useful little feature that can save some time. Here's an example.</p>
<p> </p>
<p>I've got this dataset that shows Actual and Forecast (B3:I6). My manager wants to see the difference of the two in the Forecast columns.</p>
<p>So I've entered some formulas starting in C8. The formula bar shows that I'm simply calculating the difference.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/01/012810_1419_PasteSpecia2.png" alt="" /></p>
<p> </p>
<p> </p>
<p>At this point, a lesser Excel user would copy each set of numbers individually and do a paste-special-values into each column.</p>
<p>But I'm far too an important person to inundate myself with all that copying and pasting.  So I'll copy the entire range here.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/01/012810_1419_PasteSpecia3.png" alt="" /></p>
<p> </p>
<p> </p>
<p>Then I'll call up the Paste Special dialog box and click Values. I'll also click the Skip Blanks option.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/01/012810_1419_PasteSpecia4.png" alt="" /></p>
<p> </p>
<p> </p>
<p>Booyah. Excel pastes over only the areas where there was data in the copied range. In other words, it ignored the blanks in the copied range.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2010/01/012810_1419_PasteSpecia5.png" alt="" /></p>
<p> </p>
<p> </p>
<p>There you have it – Skip Blanks. Another feature demystified.</p>
<p>I think I'll reward myself with a disgusting breakfast sandwich from McDonalds.</p>
]]></content:encoded>
			<wfw:commentRss>http://datapigtechnologies.com/blog/index.php/paste-special-skip-blanks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Flipping a Range Upside Down</title>
		<link>http://datapigtechnologies.com/blog/index.php/flipping-a-range-upside-down/</link>
		<comments>http://datapigtechnologies.com/blog/index.php/flipping-a-range-upside-down/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 08:23:14 +0000</pubDate>
		<dc:creator>datapig</dc:creator>
				<category><![CDATA[Excel Formulas]]></category>
		<category><![CDATA[Excel Tips and Tricks]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Formulas]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://datapigtechnologies.com/blog/?p=1383</guid>
		<description><![CDATA[I'm no Tiger Woods, but I get my share of lady fan mail. Today, I get an email from Dawn.
She asks: "Do you have an easy way to flip a range so that the bottom row is at the top and the top row is at the bottom?"

I have two methods for doing this.

 
Method 1: [...]]]></description>
			<content:encoded><![CDATA[<p>I'm no Tiger Woods, but I get my share of lady fan mail. Today, I get an email from Dawn.</p>
<p>She asks: <em>"Do you have an easy way to flip a range so that the bottom row is at the top and the top row is at the bottom?"<br />
</em></p>
<p>I have two methods for doing this.<em><br />
</em></p>
<p> <span id="more-1383"></span></p>
<p><span style="font-size:14pt"><strong>Method 1: The Cheap Sorting Flip<br />
</strong></span></p>
<p>If I need to do a one-time flip, I simply number my rows, and then sort in Descending order.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2009/12/120909_0822_FlippingaRa1.png" alt="" /></p>
<p> </p>
<p> </p>
<p><span style="font-size:14pt"><strong>Method 2: The Sophisticated Formula Flip<br />
</strong></span></p>
<p>If I need a more sustained way to flip a range, I use a formula.</p>
<p>The formula I typically use is: <strong>INDEX($B$2:$B$7,ROWS(B2:$B$7))<br />
</strong></p>
<p>As you can see, this formula uses the <em>INDEX</em> function and the <em>ROWS</em> function.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2009/12/120909_0822_FlippingaRa2.png" alt="" /></p>
<p>The <em>INDEX</em> function translates a position number into a value. In this example, if I were to enter<em><br />
<strong>INDEX($B$2:$B$7, 6)</strong></em>, I would get "Mia" because that is the value in the sixth position in the range.</p>
<p>The trick is to figure out how to get the correct position numbers. This is where the <em>ROWS</em> function comes in.</p>
<p>The ROWS function tells you how many rows are in a given range. In this example,<strong><br />
<em>ROWS(B2:B7)</em></strong> would return 6 because there are six rows in my selected range.</p>
<p>All I need to do is make sure that the range for the <em>INDEX</em> function remains locked, while the range for the ROWS function shrinks as I copy the formula down.</p>
<p>I do this by placing dollar signs on all references except the starting reference for the <em>ROWS</em> function - as in</p>
<p>ROWS(<span style="color: #800000;"><strong>B2</strong></span>:$B$7).</p>
<p>This allows the <em>ROWS </em>function to return decreasing row numbers as I copy the formula down, essentially feeding the <em>INDEX</em> function the needed position numbers in backwards order.</p>
<p> </p>
<p>If I need to apply this trick horizontally, I just use the <em>COLUMNS</em> function to do the same thing horizontally.</p>
<p><img src="http://datapigtechnologies.com/blog/wp-content/uploads/2009/12/120909_0822_FlippingaRa3.png" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://datapigtechnologies.com/blog/index.php/flipping-a-range-upside-down/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
