<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6769200534226549916</id><updated>2011-04-21T20:35:25.685-07:00</updated><title type='text'>MS Excel Tricks</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://exceltricks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6769200534226549916/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://exceltricks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Umesh Khot</name><uri>http://www.blogger.com/profile/18269267597913054307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6769200534226549916.post-8307181698368903370</id><published>2011-03-22T05:27:00.000-07:00</published><updated>2011-03-22T05:27:13.865-07:00</updated><title type='text'>Calculating Sum of Digits in a Number using Array Formulas</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"&gt;Given a number in cell, I want you to find the sum of digits in it. So, for eg. if you have the number 3584398594 in a cell, the sum would be =3+5+8+4+3+9+8+5+9+4, equal to 58.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;h3 style="line-height: 140%;"&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"&gt;How to get the sum of digits?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"&gt;&lt;h3 style="line-height: 140%;"&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"&gt;Formula:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style="line-height: 140%;"&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; line-height: 140%;"&gt;Assuming the number is in cell B4, we write the formula,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 140%;"&gt;&lt;code&gt;&lt;span style="color: black; font-size: 10.0pt; line-height: 140%;"&gt;=SUMPRODUCT(MID(B4,ROW(OFFSET($A$1,,,LEN(B4))),1)+0)&lt;/span&gt;&lt;/code&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; line-height: 140%;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 140%;"&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; line-height: 140%;"&gt;to get the sum of digits.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 140%;"&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; line-height: 140%;"&gt;Note: you need &lt;strong&gt;&lt;i&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt;not &lt;/span&gt;&lt;/i&gt;&lt;/strong&gt;press CTRL+SHIFT+Enter to get this formula work.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style="line-height: 140%;"&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin;"&gt;How does this formula work?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div style="line-height: 140%;"&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; line-height: 140%;"&gt;We will go inside out to understand this formula.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 140%;"&gt;&lt;strong&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; line-height: 140%;"&gt;The portion – &lt;/span&gt;&lt;/strong&gt;&lt;code&gt;&lt;b&gt;&lt;span style="color: black; font-size: 10.0pt; line-height: 140%;"&gt;ROW(OFFSET($A$1,,,LEN(B4)))&lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; line-height: 140%;"&gt;:&lt;strong&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;"&gt; &lt;/span&gt;&lt;/strong&gt;Gives the numbers 1,2,3…n where n is the number of digits of the value in B4.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 140%;"&gt;&lt;strong&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; line-height: 140%;"&gt;The portion – &lt;/span&gt;&lt;/strong&gt;&lt;code&gt;&lt;b&gt;&lt;span style="color: black; font-size: 10.0pt; line-height: 140%;"&gt;MID(B4,ROW(OFFSET($A$1,,,LEN(B4))),1)&lt;/span&gt;&lt;/b&gt;&lt;/code&gt;&lt;strong&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; line-height: 140%;"&gt;: &lt;/span&gt;&lt;/strong&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; line-height: 140%;"&gt;Now gets the individual digits of the number and returns them as array (since the 2nd argument of MID formula is an array.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 140%;"&gt;&lt;strong&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; line-height: 140%;"&gt;The SUMPRODUCT: &lt;/span&gt;&lt;/strong&gt;&lt;span style="color: black; font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; line-height: 140%;"&gt;is the pixie dust. It just magically sums up all the digits extracted by MID(). We use a +0 at the end because MID() returns text that needs to be converted to numbers for SUMPRODUCT to work its magic.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6769200534226549916-8307181698368903370?l=exceltricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://exceltricks.blogspot.com/feeds/8307181698368903370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://exceltricks.blogspot.com/2011/03/calculating-sum-of-digits-in-number.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6769200534226549916/posts/default/8307181698368903370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6769200534226549916/posts/default/8307181698368903370'/><link rel='alternate' type='text/html' href='http://exceltricks.blogspot.com/2011/03/calculating-sum-of-digits-in-number.html' title='Calculating Sum of Digits in a Number using Array Formulas'/><author><name>Umesh Khot</name><uri>http://www.blogger.com/profile/18269267597913054307</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
