<?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>array-formulas on S Anand</title>
    <link>https://www.s-anand.net/blog/tag/array-formulas/</link>
    <description>Recent content in array-formulas on S Anand</description>
    <generator>Hugo -- 0.164.0</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 23 Mar 2009 15:39:23 +0000</lastBuildDate>
    <atom:link href="https://www.s-anand.net/blog/tag/array-formulas/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Dynamically eliminate duplicates</title>
      <link>https://www.s-anand.net/blog/dynamically-eliminate-duplicates/</link>
      <pubDate>Thu, 04 Sep 2008 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/dynamically-eliminate-duplicates/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This is a series on what &lt;a href=&#34;http://docs.google.com/&#34;&gt;Google Spreadsheets&lt;/a&gt; can do that Excel can&amp;rsquo;t&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To get a list of unique values from a list, use the &lt;a href=&#34;http://documents.google.com/support/spreadsheets/bin/answer.py?hl=en-uk&amp;amp;answer=92022&#34;&gt;UNIQUE function&lt;/a&gt; on &lt;a href=&#34;http://docs.google.com/&#34;&gt;Google Spreadsheets&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For example, if you have a list of browsers in column A, type &lt;code&gt;=UNIQUE(A1:A17)&lt;/code&gt; at cell B1 to get a unique list of browsers. This is a dynamic list. If you change the list of browsers, the unique list gets updated automatically.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-11_2825546538_o-png.webp&#34;&gt;&lt;img alt=&#34;1.1&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-11_2825546538_o-png.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can use UNIQUE to &lt;strong&gt;create a dynamic pivot table&lt;/strong&gt;. Quite often, you end up creating a pivot table simply to summarise by one column. The main purpose the pivot table serves is in getting a list of unique values on that column. Plus, it&amp;rsquo;s a bit heavy on the UI. And every time the data changes, you need to refresh the pivot. But with the UNIQUE function, you can get a dynamic list of unique values, and you can use the COUNTIF and SUMIF function next to each value. Here is an example showing the frequency table of the browsers shown earlier. Column C does a COUNTIF of the unique values on the original list.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-12_2825546532_o-png.webp&#34;&gt;&lt;img alt=&#34;1.2&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-12_2825546532_o-png.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can also use UNIQUE as the input to another formula:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;=COUNT(UNIQUE(LIST))&lt;/code&gt; counts the number of unique values&lt;/p&gt;
&lt;p&gt;&lt;code&gt;=COUNT(LIST)-COUNT(UNIQUE(LIST))&lt;/code&gt; gives the number of duplicates&lt;/p&gt;
&lt;p&gt;&lt;code&gt;=INDEX(UNIQUE(LIST),3)&lt;/code&gt; gives you the third unique value&lt;/p&gt;
&lt;p&gt;&lt;code&gt;=LARGE(UNIQUE(LIST),3)&lt;/code&gt; gives you the third largest unique value&lt;/p&gt;
&lt;p&gt;&amp;hellip; and so on.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Can I do that in Excel?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can, but not easily. There are two approaches, but each has its limitations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A. Use Advanced Filters: easy but static&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create an advanced filter on column A (Alt-D-F-A)&lt;/li&gt;
&lt;li&gt;Select Copy to another location&lt;/li&gt;
&lt;li&gt;Click in the Copy to box, and then click the cell B1&lt;/li&gt;
&lt;li&gt;Select Unique records only&lt;/li&gt;
&lt;li&gt;Click OK&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-13_2825546548_o-png.webp&#34;&gt;&lt;img alt=&#34;1.3&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-13_2825546548_o-png.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But the list of unique values that you get here is static. If you changed one of the values, the list of unique values does not change.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;B. Use a complex formulae that are dynamic&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;First, blank out the duplicates by typing this formula:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;=IF(COUNTIF(A$1:A1,A1)=1,A1,&amp;quot;&amp;quot;)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;adjacent to the first cell (into B1), and dragging it all the way down (to B17).&lt;/p&gt;
&lt;p&gt;Now, create a named range (Alt-I-N-D) for these cells (B1:B17) called WithBlanks and another named range called NoBlanks for the cells one column to the right (C1:C17).&lt;/p&gt;
&lt;p&gt;On the first cell of NoBlanks (C1), type this &lt;a href=&#34;http://www.cpearson.com/&#34;&gt;formula&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;=IF(ROW()-ROW(NoBlanks)+1&amp;gt;ROWS(WithBlanks)-COUNTBLANK(WithBlanks),&amp;#34;&amp;#34;,
    INDIRECT(ADDRESS(SMALL((IF(WithBlanks&amp;lt;&amp;gt;&amp;#34;&amp;#34;,ROW(WithBlanks),ROW()+
    ROWS(WithBlanks))),ROW()-ROW(NoBlanks)+1),COLUMN(WithBlanks),4)))
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Press Ctrl-Shift-Enter rather than Enter, because it&amp;rsquo;s an array formula. Now drag this all the way down (to C17).&lt;/p&gt;
&lt;p&gt;The list in column C is dynamic. If you change a cell in column A, column C is updated. But the formula can only handle one column. Google Spreadsheets&amp;rsquo; UNIQUE function works with any number of columns. If you had data in the range A1:D100 and wanted the unique rows, UNIQUE(A1:D100) gets that for you.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-14_2825546554_o-png.webp&#34;&gt;&lt;img alt=&#34;1.4&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-14_2825546554_o-png.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: I&amp;rsquo;m staying away from &lt;a href=&#34;https://www.s-anand.net/blog/user-defined-functions-in-excel/&#34;&gt;user defined functions&lt;/a&gt;. You could, of course, create a UNIQUE function in Excel using Visual Basic. In fact, you should!&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;Ken J&lt;/strong&gt; &lt;em&gt;19 Sep 2008 1:10 pm&lt;/em&gt;:
Great entry. I love your site. It is perfect for advanced users.&lt;br&gt;
&lt;br&gt;
Let&amp;rsquo;s hope Google&amp;rsquo;s pressure will force some innovation at excel.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://www.isheet.com&#34;&gt;hk&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;21 May 2009 3:30 am&lt;/em&gt;:
What about Data/Consolidate from menu?&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 to get cell formatting</title>
      <link>https://www.s-anand.net/blog/user-defined-functions-to-get-cell-formatting/</link>
      <pubDate>Sat, 02 Sep 2006 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/user-defined-functions-to-get-cell-formatting/</guid>
      <description>&lt;p&gt;Sometimes you want to check the colour of a cell, or whether a cell is bold. This can be easily done with user-defined functions (UDFs). (To create a UDF, press Alt-F11, Alt-I-M, and type the code below.)&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-user-defined-functions-to-get-the-background-colour-and-bold-value-of-a-cell_231663146_o-gif.webp&#34;&gt;&lt;img alt=&#34;User defined functions to get the background colour and bold value of a cell&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-user-defined-functions-to-get-the-background-colour-and-bold-value-of-a-cell_231663146_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can use ISBOLD(cell) to check if a cell is bold, and BGCOLOR(cell) to get the background colour of the cell. This lets you selectively process bold or shaded cells. The two examples below show how you can add only the cells in bold, or only the shaded cells.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-example-to-selectively-add-shaded-cells_231663147_o-gif.webp&#34;&gt;&lt;img alt=&#34;Example to selectively add shaded cells&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-example-to-selectively-add-shaded-cells_231663147_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-example-to-selectively-add-bold-cells_231663148_o-gif.webp&#34;&gt;&lt;img alt=&#34;Example to selectively add bold cells&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-example-to-selectively-add-bold-cells_231663148_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Rather than use an additional column for ISBOLD or BGCOLOR, you can use an array formula, like below. (Remember to press &lt;strong&gt;Ctrl-Shift-Enter&lt;/strong&gt; instead of Enter after typing this formula)&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-example-to-selectively-add-bold-cells-using-a-single-array-formula_231663149_o-gif.webp&#34;&gt;&lt;img alt=&#34;Example to selectively add bold cells using a single array formula&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-example-to-selectively-add-bold-cells-using-a-single-array-formula_231663149_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But first, you need to change the &lt;a href=&#34;http://www.google.com/search?&amp;amp;q=excel+user+defined+function+%22return+an+array%22&#34;&gt;UDF to return an array&lt;/a&gt; rather than a single value. So IsBold will have to be modified as shown.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-user-defined-function-isbold-modified-to-return-an-array_231669052_o-gif.webp&#34;&gt;&lt;img alt=&#34;User defined function isBold modified to return an array&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-user-defined-function-isbold-modified-to-return-an-array_231669052_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;User-defined functions that process arrays can be very powerful. It can bring the full power of functional programming into Excel. I&amp;rsquo;ll describe some next week.&lt;/p&gt;
&lt;p&gt;PS: In case you&amp;rsquo;re wondering, &lt;code&gt;Application.Volatile&lt;/code&gt; tells Excel to recalculate the function every time the worksheet is recalculated. When a cell is made bold, or shaded, the &lt;strong&gt;value&lt;/strong&gt; of the cell doesn&amp;rsquo;t change. So Excel doesn&amp;rsquo;t recalculate any formulas. You&amp;rsquo;ll have to manually press F9 every time to recalculate these cells. And &lt;code&gt;Application.Volatile&lt;/code&gt; ensures that when you press F9, these functions are recalculated.&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;Ramly&lt;/strong&gt; &lt;em&gt;19 Mar 2007 3:07 pm&lt;/em&gt;:
good&amp;hellip; May i ask your help to give me a solution for my problem&amp;hellip; I always use vlookup to find some data in a specific range, my lookup value are employee code number then look for there name, age, address and so on. but today, i want look up a value with multiple returns. i want to have the some of a worker which he have in a specific date. Please give help regarding this matter.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Prasath&lt;/strong&gt; &lt;em&gt;13 Nov 2009 10:00 am&lt;/em&gt;:
Hi Need a help
The ISBOLD function which is defined on top does not work if I change the cell which is Bold to Unbold.
The formula should work automatically if a cell is changed BOLD or UNBOLD&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>Excel - Avoid manual labour 5</title>
      <link>https://www.s-anand.net/blog/excel-avoid-manual-labour-5/</link>
      <pubDate>Wed, 21 Dec 2005 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/excel-avoid-manual-labour-5/</guid>
      <description>&lt;p&gt;A few tips, without getting into the details. &lt;a href=&#34;http://www.google.com/search?q=excel+array+formulas&#34;&gt;Array formulas&lt;/a&gt; let you perform any calculation on an entire list, and get the result in a single formula. &lt;a href=&#34;http://www.google.com/search?q=excel+database+functions+DSUM&#34;&gt;Database functions&lt;/a&gt; like DSUM can manipulate tables of data very flexibly. Using these and &lt;a href=&#34;http://www.google.com/search?q=excel+pivot+tables&#34;&gt;Pivot tables&lt;/a&gt;, you can do anything with any tabular data.&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;Ananth&lt;/strong&gt; &lt;em&gt;22 Dec 2005 6:32 am&lt;/em&gt;:
I needed your feedback on &lt;a href=&#34;https://www.doondo.org&#34;&gt;www.doondo.org&lt;/a&gt;. Give it a spin let me know. I wanted to avoid positng here but never got any replies for the mails sent at root_node at yahoo.com&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ananth&lt;/strong&gt; &lt;em&gt;22 Dec 2005 6:33 am&lt;/em&gt;:
&lt;a href=&#34;https://www.doondo.org&#34;&gt;www.doondo.org&lt;/a&gt; is a hobby project I&amp;rsquo;ve been working on. The beta is just out.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ananth&lt;/strong&gt; &lt;em&gt;22 Dec 2005 6:35 am&lt;/em&gt;:
Looking forward for your views and feedback&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ritzkini&lt;/strong&gt; &lt;em&gt;22 Dec 2005 10:01 am&lt;/em&gt;:
great concept ananth..shld be a hit considering the great response to a similar funda used in IIM-I&amp;rsquo;s Klueless&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;22 Dec 2005 12:31 pm&lt;/em&gt;:
I liked the concept and interface, Ananth. Will mail you in detail. Quick question&amp;hellip; how do I find out what the right keywords are?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ritzkini&lt;/strong&gt; &lt;em&gt;23 Dec 2005 2:19 am&lt;/em&gt;:
hehehe&amp;hellip;hey anand,saw the visitor stats thing for the first time today ! awesomely cool ,kudos! u did it yourself ??&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dhar&lt;/strong&gt; &lt;em&gt;23 Dec 2005 3:26 am&lt;/em&gt;:
Ananth, does your game support advanced Google operators?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ananth&lt;/strong&gt; &lt;em&gt;23 Dec 2005 4:11 am&lt;/em&gt;:
Thanks for feedback folks. doondo needs additional features, like game summary with right keywords. Right now only basic operators are supported. Even such a simple concept requires complex coding skills! I would love if you can post the suggestion at &lt;a href=&#34;mailto:doondo@googlegroups.com&#34;&gt;doondo@googlegroups.com&lt;/a&gt;. Great if you can join the group. Anand wouldn&amp;rsquo;t like spamming his comments section with doondo.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;24 Dec 2005 1:42 am&lt;/em&gt;:
Yeah ritzkini, spent a week coding the visitor stats. What else do you think would be useful to see?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ritzkini&lt;/strong&gt; &lt;em&gt;26 Dec 2005 7:22 am&lt;/em&gt;:
:) i dont think it could have been any more comprehensive than it already is ! :)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;harish&lt;/strong&gt; &lt;em&gt;11 Jan 2006 3:50 am&lt;/em&gt;:
great work mate&amp;hellip;&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
  </channel>
</rss>
