<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>user-defined-functions on S Anand</title>
    <link>https://www.s-anand.net/blog/tag/user-defined-functions/</link>
    <description>Recent content in user-defined-functions on S Anand</description>
    <generator>Hugo -- 0.164.0</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 23 Mar 2009 15:39:30 +0000</lastBuildDate>
    <atom:link href="https://www.s-anand.net/blog/tag/user-defined-functions/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Web lookup using Excel</title>
      <link>https://www.s-anand.net/blog/web-lookup-using-excel/</link>
      <pubDate>Thu, 03 May 2007 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/web-lookup-using-excel/</guid>
      <description>&lt;p&gt;Take a look at the Excel screenshot below.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-amazon-web-prices_481952444_o-png.webp&#34;&gt;&lt;img alt=&#34;Amazon Web Prices&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-amazon-web-prices_481952444_o-png.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Yes, that&amp;rsquo;s right. I have a &lt;a href=&#34;https://www.s-anand.net/blog/user-defined-functions-in-excel/&#34;&gt;user-defined function&lt;/a&gt; called AMAZONPRICE. And it returns these cameras&amp;rsquo; &lt;strong&gt;prices directly from Amazon.com&lt;/strong&gt;. (Given the category and some keywords, it returns the price of the bestselling item on Amazon.com.)&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s the code behind the function.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;Function&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;AmazonPrice&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;index&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;keywords&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;String&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;Dim&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;MSXML2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;DOMDocument30&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;Set&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;New&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;MSXML2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;DOMDocument30&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;kr&#34;&gt;async&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;False&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;If&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Load&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&amp;#34;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;_&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;amp;Version=2005-03-23&amp;amp;Operation=ItemSearch&amp;amp;SubscriptionId=03SDGQDFEB455W53SB82&amp;#34;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;_&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;amp;AssociateTag=sanand-20&amp;amp;MinimumPrice=10000&amp;amp;ResponseGroup=OfferSummary,Small&amp;#34;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;_&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;amp;Sort=salesrank&amp;amp;SearchIndex=&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;index&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;amp;Keywords=&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;keywords&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Then&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;setProperty&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;SelectionLanguage&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;XPath&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;setProperty&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;SelectionNamespaces&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;_&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;s2&#34;&gt;&amp;#34;xmlns:a=&amp;#34;&amp;#34;http://webservices.amazon.com/AWSECommerceService/2005-03-23&amp;#34;&amp;#34;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;AmazonPrice&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;selectSingleNode&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;/a:ItemSearchResponse//a:Amount&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Text&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;End&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;If&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;End&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;Function&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;
&lt;p&gt;This is how it all started&amp;hellip;&lt;/p&gt;
&lt;p&gt;Flickr has a &lt;a href=&#34;http://www.flickr.com/cameras/&#34;&gt;camera finder&lt;/a&gt; that shows the most popular cameras in the Flickr community.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-flickr-camera-finder_481952446_o-png.webp&#34;&gt;&lt;img alt=&#34;flickr Camera Finder&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-flickr-camera-finder_481952446_o-png.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I &lt;a href=&#34;https://www.s-anand.net/blog/how-i-buy-gadgets/&#34;&gt;love comparing gadgets&lt;/a&gt;, I&amp;rsquo;d been doing some research around these cameras, and the &lt;a href=&#34;http://www.flickr.com/cameras/fujifilm/&#34;&gt;Fuji series&lt;/a&gt; (because I own a &lt;a href=&#34;https://www.s-anand.net/blog/my-fuji-finepix-s5600/&#34;&gt;Fuji Finepix S5600&lt;/a&gt;). I&amp;rsquo;d normally make a spreadsheet that compares these cameras on various parameters, including price.&lt;/p&gt;
&lt;p&gt;Since I believe in &lt;a href=&#34;https://www.s-anand.net/blog/excel-never-type-in-data/&#34;&gt;never typing in data&lt;/a&gt;, wondered if there was a way to get the prices in automatically&amp;hellip;&lt;/p&gt;
&lt;p&gt;Two things made this possible.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Amazon offers &lt;a href=&#34;http://www.amazon.com/gp/browse.html?node=3435361&#34;&gt;web services&lt;/a&gt; which let you get price (and almost any other) data for their products&lt;/li&gt;
&lt;li&gt;Visual Basic lets you use pretty much any ActiveX object as a control. Microsoft offers &lt;a href=&#34;http://msdn2.microsoft.com/en-us/xml/bb291077.aspx&#34;&gt;MSXML&lt;/a&gt; which you can use to load (or download) any XML file, and parse it.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first task is to get the XML feed for a product you want. Amazon lets you do that through by typing in a URL. The best way to construct the URL is through &lt;a href=&#34;http://www.awszone.com/&#34;&gt;AWSZone&lt;/a&gt;. I picked the &lt;a href=&#34;http://www.awszone.com/scratchpads/aws/ecs.us/ItemSearch.aws&#34;&gt;US ItemSearch&lt;/a&gt; method, which searches for a title or keyword within a category, and returns the matches. The feed for the Canon EOS Digital Rebel XT, based on this, would be at:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;http://ecs.amazonaws.com/onca/xml?
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    Service=AWSECommerceService&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    Version=2005-03-23&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    Operation=ItemSearch&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    SubscriptionId=0525E2PQ81DD7ZTWTK82&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    SearchIndex=Electronics&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    Keywords=Canon EOS Digital Rebel XT&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    Sort=salesrank&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    ResponseGroup=Offers,Small
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;(You really need to replace the Subscription ID with your own.)&lt;/p&gt;
&lt;p&gt;If you &lt;a href=&#34;http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&amp;amp;Version=2005-03-23&amp;amp;Operation=ItemSearch&amp;amp;SubscriptionId=0525E2PQ81DD7ZTWTK82&amp;amp;SearchIndex=Electronics&amp;amp;Keywords=Canon%20EOS%20Digital%20Rebel%20XT&amp;amp;Sort=salesrank&amp;amp;ResponseGroup=Offers,Small&#34;&gt;retrieved this URL&lt;/a&gt;, you have an XML file containing the details of all Canon EOS Digital Rebel XTs, sorted by sales rank.&lt;/p&gt;
&lt;p&gt;To load this in Excel, you need to create a &lt;a href=&#34;https://www.s-anand.net/blog/user-defined-functions-in-excel/&#34;&gt;UDF&lt;/a&gt; in Visual Basic. First, go to &lt;strong&gt;Tools - References and enable Microsoft XML, v3.0 or v4.0&lt;/strong&gt;. Now, to load an XML document, do this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-vb&#34; data-lang=&#34;vb&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;Dim&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;MSXML2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;DOMDocument30&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;Set&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;New&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;MSXML2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;DOMDocument30&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;async&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;False&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Load&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;url&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the load succeeds, then you can extract the information fairly easily, using &lt;a href=&#34;http://www.w3.org/TR/xpath&#34;&gt;XPath&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-vb&#34; data-lang=&#34;vb&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;setProperty&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;SelectionLanguage&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;XPath&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;setProperty&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;SelectionNamespaces&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; _
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s&#34;&gt;&amp;#34;xmlns:a=&amp;#34;&amp;#34;http://webservices.amazon.com/AWSECommerceService/2005-03-23&amp;#34;&amp;#34;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The first line says we&amp;rsquo;ll be searching using XPath. The second line is a &lt;a href=&#34;http://support.microsoft.com/kb/313372&#34;&gt;workaround to support default namespaces&lt;/a&gt;. (Don&amp;rsquo;t worry about it. I don&amp;rsquo;t quite get it either.)&lt;/p&gt;
&lt;p&gt;Finally, you get the price from the XML tree. In this case, it&amp;rsquo;s under ItemSearchResponse/Items/Item/OfferSummary/LowestNewPrice/Amount, and it&amp;rsquo;s in cents.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-vb&#34; data-lang=&#34;vb&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;AmazonPrice&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;selectSingleNode&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;/a:ItemSearchResponse//a:Amount&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Text&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That&amp;rsquo;s it! Now that this function is defined, just pass it the category and keywords, and you have the price of the first matching product. You can retrieve any other information about products as well &amp;ndash; like sales rank, weight, ratings, reviews, etc.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Here&amp;rsquo;s the &lt;a href=&#34;https://files.s-anand.net/blog/a/AmazonPrices.xls&#34;&gt;spreadsheet&lt;/a&gt; for you to play around with.&lt;/p&gt;
&lt;hr&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://www.amazon.com/gp/product/0764540726&#34;&gt;Excel 2003 Power Programming with VBA (Excel Power Programming With Vba&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://www.amazon.com/gp/product/0596003595&#34;&gt;Writing Excel Macros with VBA, 2nd Edition&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Saurabh&lt;/strong&gt; &lt;em&gt;3 May 2007 7:38 am&lt;/em&gt;:
There is a simpler way as well. Use Data-&amp;gt;Import External Data-&amp;gt;New Web Query. While this is not as powerful as the user defined function that you have created, but definitely a good starting point for lesser geeks :) I use this, for example, to have a dashboard kind of view for the status of the multiple projects that I handle at my work. We rely heavily on Microsoft Sharepoint at work, and using the Web Query option, I can easily get a snapshot of the status of various projects. Same can also fetch shareprices from various websites.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;3 May 2007 8:16 am&lt;/em&gt;:
Good point, Saurabh! Web Query does make getting stuff out of HTML very easy. My function operates in a different domain, though. It can access XML, which Web Query won&amp;rsquo;t, but can&amp;rsquo;t access HTML, which Web Query does. I&amp;rsquo;m planning a few more posts on how to extend this concept&amp;hellip; that will explain what I mean.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;rick sherrin&lt;/strong&gt; &lt;em&gt;3 May 2007 12:00 pm&lt;/em&gt;:
Hi, I work at a public library, in the acquisitions department. The majority of the work is manually keying in order information (that is available electronically elsewhere). I read your article about using Excel to retrieve amazon information. This is something that would be very useful to our library and would make my job easier. I have a little excel knowledge, but I have no experience with visual basic or xml, etc. So although it looks straightforward, it is still out of my reach. I would like to be able to enter a column of ISBN numbers in one column, and retrieve title, author, publisher, price, reviews, synopsis, cover image, in adjacent columns. I would appreciate your help if you would give me an example of how I could easily do this. Thanks Rick&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;dat&lt;/strong&gt; &lt;em&gt;12 Aug 2008 8:10 am&lt;/em&gt;:
useful article!
Btw, how do I retrieve other info from amazon (published date, sales rank, customer review, etc)???
thanks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;13 Aug 2008 2:15 am&lt;/em&gt;:
@dat: Have a look at &lt;a href=&#34;http://www.awszone.com/&#34;&gt;http://www.awszone.com/&lt;/a&gt; for examples on other parameters.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lydia&lt;/strong&gt; &lt;em&gt;3 May 2010 12:05 am&lt;/em&gt;:
this worked until august last year when amazon changed the way the query signs into their system&amp;hellip;it now requires a signature with a timestamp in addition to the subscription ID&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bobby Baker&lt;/strong&gt; &lt;em&gt;10 Feb 2015 7:09 am&lt;/em&gt;:
Have you updated the search functions for this or do you have a new code for this?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Vlad&lt;/strong&gt; &lt;em&gt;26 Aug 2015 10:00 pm&lt;/em&gt;:
Hey Annand
is it possible o get the racking status fro fedex for a column of tracking numbers?&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>User defined array functions in Excel</title>
      <link>https://www.s-anand.net/blog/user-defined-array-functions-in-excel/</link>
      <pubDate>Fri, 23 Feb 2007 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/user-defined-array-functions-in-excel/</guid>
      <description>&lt;p&gt;Many languages have functions to process lists (array). These functions usually return a list, so you can pass that to another list function. This chaining of functions is really powerful.&lt;/p&gt;
&lt;p&gt;UNIX provides this sort of chaining capability. If I had a cities (with some repetitions) and I wanted to find out how many started with the letter &amp;lsquo;A&amp;rsquo;, I&amp;rsquo;d just type:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cat cities &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; sort &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; uniq &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; grep &lt;span class=&#34;s2&#34;&gt;&amp;#34;^A&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; wc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;cat&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;types the cities.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;sort&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;sorts the cities alphabetically.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;uniq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;finds unique cities (works only if sorted - that&amp;#39;s why we had to sort the list).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;grep&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;filters the cities. Only allows cities beginning with A.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;wc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;word count&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To do this on Excel, the only way is to&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;get the unique values&lt;/strong&gt;. Data - Filter - Advanced Filter, and select &amp;ldquo;Unique records only&amp;rdquo;, &amp;ldquo;Copy the list to another location&amp;rdquo;, and select a location&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;get the first letter&lt;/strong&gt;. =LEFT(cell,1) returns the first letter of the cell.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;count the number of &amp;ldquo;A&amp;quot;s&lt;/strong&gt;. =COUNT(range, &amp;ldquo;A&amp;rdquo;) counts the number of &amp;ldquo;A&amp;quot;s.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;But ideally, I&amp;rsquo;d like a 1-line formula like&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;=LENGTH(UNIQUE(GREP(&amp;#34;^A&amp;#34;, range)))
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Excel doesn&amp;rsquo;t provide these functions by default, but you can add them as &lt;a href=&#34;https://www.s-anand.net/blog/user-defined-functions-in-excel/&#34;&gt;user defined functions&lt;/a&gt;. Doing this &lt;strong&gt;lets you condense several cells into one&lt;/strong&gt;. Instead of having to copy all your data into a set of unique values, and then adding a column for the first cell, the entire operation can be condensed into one formula.&lt;/p&gt;
&lt;p&gt;I consider the following functions the a basic set for list processing.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LENGTH(list) counts the number of elements in a list&lt;/li&gt;
&lt;li&gt;INDEX(list, n) returns the nth element of the list&lt;/li&gt;
&lt;li&gt;GREP(string, list) returns elements of the list that have the string&lt;/li&gt;
&lt;li&gt;UNIQUE(list) filters unique values&lt;/li&gt;
&lt;li&gt;UNION(list, list) returns elements in at least one of the lists&lt;/li&gt;
&lt;li&gt;INTERSECTION(list, list) returns elements in both lists&lt;/li&gt;
&lt;li&gt;DIFFERENCE(list, list) returns the elements in the first list but not the second&lt;/li&gt;
&lt;li&gt;REVERSE(list) reverses the order of the list&lt;/li&gt;
&lt;li&gt;STRJOIN(separator, list) joins the elements of the list into a string, separated by a separator&lt;/li&gt;
&lt;li&gt;STRSPLIT(separator, string) splits the string into a list, using a separator&lt;/li&gt;
&lt;li&gt;MVLOOKUP(value, lookup, result) looks up value in &amp;ldquo;lookup&amp;rdquo;, and returns the corresponding MULTIPLE values from &amp;ldquo;result&amp;rdquo;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I created these UDFs. You can &lt;a href=&#34;https://files.s-anand.net/blog/a/Macros.xls&#34;&gt;download the functions&lt;/a&gt; and play with them. Below are some tasks that you can do with them, that are difficult otherwise.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Get the file name from a path.
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;=INDEX(REVERSE(STRSPLIT(&amp;rdquo;&amp;quot;, filename)), 1)&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- Count the number of unique elements in a range.
  ```excel
=LENGTH(UNIQUE(range))
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;How many common elements are there in range 1 and range 2?
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;=LENGTH(INTERSECTION(range1, range2))&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- How many words are there in a string?
  ```excel
=LENGTH(STRSPLIT(&amp;#34; &amp;#34;, string))
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;Get the smallest unique numbers in a range
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;=SMALL(UNIQUE(range), 5)&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- Count the number of mismatches between two lists.
  ```excel
=COUNT(Range1)+COUNT(Range2) - COUNT(INTERSECTION(Range1,Range2))
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;Get a list of mismatches between two lists.
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;=STRJOIN(&amp;rdquo;,&amp;quot;,UNION(DIFFERENCE(Range1,Range2), DIFFERENCE(Range2,Range1)))&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- Count duplicate entries in a range.
  ```excel
=LENGTH(Range)-LENGTH(UNIQUE(Range))
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;VLOOKUP multiple values
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;=MVLOOKUP(A1,Lookup_Range,Return_Range)&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- Count the unique matches in a VLOOKUP
  ```excel
=COUNT(UNIQUE(MVLOOKUP(A1,Lookup_Range,Return_Range)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This is a small sample. The power of list processing is phenomenal, especially when combined with array formulas. &lt;a href=&#34;https://files.s-anand.net/blog/a/Macros.xls&#34;&gt;Download these macros&lt;/a&gt; and play with them!&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Krishna&lt;/strong&gt; &lt;em&gt;24 Feb 2007 4:10 am&lt;/em&gt;:
Anand, thanks for an extremely useful stuff.In connection to our discussion on enhancing my excel skills, i think it would help me largely. Krishna&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sundar&lt;/strong&gt; &lt;em&gt;26 Feb 2007 4:06 am&lt;/em&gt;:
Very neat job Anand. Congrats for a super job. Waht is your e-mail address? Thanx in advance&amp;hellip;&amp;hellip;&amp;hellip;&amp;hellip;S.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Anand Srini&lt;/strong&gt; &lt;em&gt;26 Feb 2007 9:40 pm&lt;/em&gt;:
Hi I reproduce this extract from your article &amp;ldquo;Instead of having to copy all your data into a set of unique values, and then adding a column for the first cell, the entire operation can be condensed into one formula&amp;rdquo; can you explain why a column has to be added for the first cell ?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ashwin&lt;/strong&gt; &lt;em&gt;27 Feb 2007 4:41 pm&lt;/em&gt;:
Dear Anand, As usual; another useful post from you. Thanks, Ashwin&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Kabir&lt;/strong&gt; &lt;em&gt;5 Mar 2007 9:01 pm&lt;/em&gt;:
you truly are a genius&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shiva&lt;/strong&gt; &lt;em&gt;6 Mar 2007 2:03 pm&lt;/em&gt;:
Your site is turning to a Dexters Laboratory&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ramly&lt;/strong&gt; &lt;em&gt;19 Mar 2007 4:35 pm&lt;/em&gt;:
Thank you very much this will help a lot&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mansi&lt;/strong&gt; &lt;em&gt;11 Apr 2007 4:22 am&lt;/em&gt;:
Hi, was just randomly searching for how to generate unique values on excel.. and came across your website. Must say, truly impressive work and this has helped me a lot! Thank you and keep up the good work! :)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;James&lt;/strong&gt; &lt;em&gt;23 Feb 2007 12:00 pm&lt;/em&gt;:
Cheers, a lot of great stuff here, makes my Excel work much easier. My hat off to you!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pete Watkins&lt;/strong&gt; &lt;em&gt;23 Feb 2007 12:00 pm&lt;/em&gt;:
Thanks ever so much for your work in developing these functions, as these have allowed me to avoid a huge amount of drudgery in processing data!&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>User-defined functions in Excel</title>
      <link>https://www.s-anand.net/blog/user-defined-functions-in-excel/</link>
      <pubDate>Fri, 01 Sep 2006 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/user-defined-functions-in-excel/</guid>
      <description>&lt;p&gt;Excel lets you create your own functions. If you wanted to create a function that returned the distance between two points (x1,y1) and (x2,y2), you can create a function DIST that takes these 4 parameters, and use it as shown below.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-example-of-a-user-defined-function-in-excel_231273003_o-gif.webp&#34;&gt;&lt;img alt=&#34;Example of a user-defined function in Excel&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-example-of-a-user-defined-function-in-excel_231273003_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To create such a function,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;press Alt-F11 to open the Visual Basic Editor&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;insert a new module (Alt-I-M)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;type the following code:&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-visual-basic-code-for-the-dist-user-defined-excel-function_231278952_o-gif.webp&#34;&gt;&lt;img alt=&#34;Visual Basic code for the DIST user-defined Excel function&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-visual-basic-code-for-the-dist-user-defined-excel-function_231278952_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Anything you declare as a &amp;ldquo;Function&amp;rdquo; in Excel&amp;rsquo;s Visual Basic automatically becomes visible in the Insert-Function dialog box under the category &amp;ldquo;User Defined&amp;rdquo; (see &lt;a href=&#34;http://www.dailydoseofexcel.com/archives/category/vba/user-defined-functions/&#34;&gt;examples&lt;/a&gt;). The function is normally saved with the file. This is a good idea if you&amp;rsquo;re going to distribute the file. You can also save your functions in your &lt;a href=&#34;http://www.google.com/search?q=personal.xls&amp;amp;btnI=I&#39;m+Feeling+Lucky&#34;&gt;personal.xls&lt;/a&gt; file and load it on startup.&lt;/p&gt;
&lt;p&gt;There are 3 places where I suggest using UDFs.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You need to repeat a formula or use an additional cell to get the job done (e.g. replace Excel errors with empty strings)&lt;/li&gt;
&lt;li&gt;You &lt;a href=&#34;https://www.s-anand.net/blog/user-defined-functions-to-get-cell-formatting/&#34;&gt;can&amp;rsquo;t get the information&lt;/a&gt; from a formula (e.g. a cell&amp;rsquo;s background colour)&lt;/li&gt;
&lt;li&gt;It&amp;rsquo;s very cumbersome to get the information using formulas (e.g. regular expressions)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let&amp;rsquo;s take the first one: &lt;strong&gt;replace Excel errors with empty strings&lt;/strong&gt;. Normally, you&amp;rsquo;d store the results in a cell (say A2), and have another cell with the formula =IF(ISERROR(A2),&amp;quot;&amp;quot;,A2). Instead, create this function NOERROR:&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-function-noerror-in-excel-visual-basic_231297813_o-gif.webp&#34;&gt;&lt;img alt=&#34;Function NOERROR in Excel Visual Basic&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-function-noerror-in-excel-visual-basic_231297813_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now you can enclose any Excel function inside a NOERROR() and it&amp;rsquo;ll filter out the errors.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-how-the-noerror-function-is-used_231297815_o-gif.webp&#34;&gt;&lt;img alt=&#34;How the NOERROR function is used&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-how-the-noerror-function-is-used_231297815_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Notice that cell E2 would&amp;rsquo;ve had a #N/A error if you&amp;rsquo;d just used the VLOOKUP. This function also filters out #REF, #DIV/0!, #NAME? and all other errors.&lt;/p&gt;
&lt;p&gt;BTW, you see column F displaying the formula in column E. I didn&amp;rsquo;t type it out. That&amp;rsquo;s another UDF.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-formulastring-function-returns-the-formula-of-a-cell_231297817_o-gif.webp&#34;&gt;&lt;img alt=&#34;FormulaString function returns the formula of a cell&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-formulastring-function-returns-the-formula-of-a-cell_231297817_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I will talk about the other two places where you use UDFs tomorrow.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Greg&lt;/strong&gt; &lt;em&gt;4 Apr 2007 3:15 pm&lt;/em&gt;:
This is very helpful! I am having a problem however; I defined the functions in personal.xls (loaded upon startup) and they always work there, but they aren&amp;rsquo;t available when working with a different file (I get the #NAME error). I also then created variants of them in the specific file, but although they worked, once I made some changes in the file (added a column), they no longer worked even though I re-did the reference properly. Any ideas?&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
  </channel>
</rss>
