<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Decimal To Binary</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2005/12/02/decimal-to-binary/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2005/12/02/decimal-to-binary/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Tue, 07 Feb 2012 23:32:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Chris Green</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/12/02/decimal-to-binary/#comment-65370</link>
		<dc:creator>Chris Green</dc:creator>
		<pubDate>Tue, 02 Aug 2011 07:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1292#comment-65370</guid>
		<description>&lt;p&gt;There appears to be a tradition of multiple posts here, so here goes, for 24 bits:&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container text default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;text codecolorer&quot;&gt;=CONCATENATE(&lt;br&gt;
IF(MOD(E2,2^24)&gt;=2^23,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^23)&gt;=2^22,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^22)&gt;=2^21,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^21)&gt;=2^20,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^20)&gt;=2^19,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^19)&gt;=2^18,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^18)&gt;=2^17,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^17)&gt;=2^16,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^16)&gt;=2^15,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^15)&gt;=2^14,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^14)&gt;=2^13,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^13)&gt;=2^12,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^12)&gt;=2^11,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^11)&gt;=2^10,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^10)&gt;=2^9,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^9)&gt;=2^8,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^8)&gt;=2^7,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^7)&gt;=2^6,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^6)&gt;=2^5,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^5)&gt;=2^4,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^4)&gt;=2^3,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^3)&gt;=2^2,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^2)&gt;=2^1,&quot;1&quot;,&quot;0&quot;),&lt;br&gt;
IF(MOD(E2,2^1)&gt;=2^0,&quot;1&quot;,&quot;0&quot;))&lt;/div&gt;&lt;/div&gt;
</description>
		<content:encoded><![CDATA[<p>There appears to be a tradition of multiple posts here, so here goes, for 24 bits:</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container text default">
<div style="white-space: nowrap;" class="text codecolorer">=CONCATENATE(<br />
IF(MOD(E2,2^24)&gt;=2^23,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^23)&gt;=2^22,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^22)&gt;=2^21,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^21)&gt;=2^20,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^20)&gt;=2^19,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^19)&gt;=2^18,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^18)&gt;=2^17,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^17)&gt;=2^16,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^16)&gt;=2^15,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^15)&gt;=2^14,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^14)&gt;=2^13,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^13)&gt;=2^12,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^12)&gt;=2^11,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^11)&gt;=2^10,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^10)&gt;=2^9,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^9)&gt;=2^8,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^8)&gt;=2^7,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^7)&gt;=2^6,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^6)&gt;=2^5,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^5)&gt;=2^4,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^4)&gt;=2^3,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^3)&gt;=2^2,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^2)&gt;=2^1,&#8221;1&#8243;,&#8221;0&#8243;),<br />
IF(MOD(E2,2^1)&gt;=2^0,&#8221;1&#8243;,&#8221;0&#8243;))</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Green</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/12/02/decimal-to-binary/#comment-65333</link>
		<dc:creator>Chris Green</dc:creator>
		<pubDate>Fri, 29 Jul 2011 16:08:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1292#comment-65333</guid>
		<description>&lt;p&gt;Was looking for a formula (not VBA), found this page, kept on looking, gave up looking, came up with the following instead.&lt;br&gt;
Gives you 12-bit binary, no negative numbers, craps out on larger numbers.&lt;br&gt;
Only have German version of xl on hand ... VERKETTEN &gt; CONCAT, WENN &gt; IF, REST &gt; MOD&lt;br&gt;
Example for cell E2:&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container text default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;text codecolorer&quot;&gt;=VERKETTEN(&lt;br&gt;
WENN(REST(E2;4096)&gt;=2048;&quot;1&quot;;&quot;0&quot;);&lt;br&gt;
WENN(REST(E2;2048)&gt;=1024;&quot;1&quot;;&quot;0&quot;);&lt;br&gt;
WENN(REST(E2;1024)&gt;=512;&quot;1&quot;;&quot;0&quot;);&lt;br&gt;
WENN(REST(E2;512)&gt;=256;&quot;1&quot;;&quot;0&quot;);&lt;br&gt;
WENN(REST(E2;256)&gt;=128;&quot;1&quot;;&quot;0&quot;);&lt;br&gt;
WENN(REST(E2;128)&gt;=64;&quot;1&quot;;&quot;0&quot;);&lt;br&gt;
WENN(REST(E2;64)&gt;=32;&quot;1&quot;;&quot;0&quot;);&lt;br&gt;
WENN(REST(E2;32)&gt;=16;&quot;1&quot;;&quot;0&quot;);&lt;br&gt;
WENN(REST(E2;16)&gt;=8;&quot;1&quot;;&quot;0&quot;);&lt;br&gt;
WENN(REST(E2;8)&gt;=4;&quot;1&quot;;&quot;0&quot;);&lt;br&gt;
WENN(REST(E2;4)&gt;=2;&quot;1&quot;;&quot;0&quot;);&lt;br&gt;
WENN(REST(E2;2)&gt;=1;&quot;1&quot;;&quot;0&quot;))&lt;/div&gt;&lt;/div&gt;
</description>
		<content:encoded><![CDATA[<p>Was looking for a formula (not VBA), found this page, kept on looking, gave up looking, came up with the following instead.<br />
Gives you 12-bit binary, no negative numbers, craps out on larger numbers.<br />
Only have German version of xl on hand &#8230; VERKETTEN &gt; CONCAT, WENN &gt; IF, REST &gt; MOD<br />
Example for cell E2:</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container text default">
<div style="white-space: nowrap;" class="text codecolorer">=VERKETTEN(<br />
WENN(REST(E2;4096)&gt;=2048;&#8221;1&#8243;;&#8221;0&#8243;);<br />
WENN(REST(E2;2048)&gt;=1024;&#8221;1&#8243;;&#8221;0&#8243;);<br />
WENN(REST(E2;1024)&gt;=512;&#8221;1&#8243;;&#8221;0&#8243;);<br />
WENN(REST(E2;512)&gt;=256;&#8221;1&#8243;;&#8221;0&#8243;);<br />
WENN(REST(E2;256)&gt;=128;&#8221;1&#8243;;&#8221;0&#8243;);<br />
WENN(REST(E2;128)&gt;=64;&#8221;1&#8243;;&#8221;0&#8243;);<br />
WENN(REST(E2;64)&gt;=32;&#8221;1&#8243;;&#8221;0&#8243;);<br />
WENN(REST(E2;32)&gt;=16;&#8221;1&#8243;;&#8221;0&#8243;);<br />
WENN(REST(E2;16)&gt;=8;&#8221;1&#8243;;&#8221;0&#8243;);<br />
WENN(REST(E2;8)&gt;=4;&#8221;1&#8243;;&#8221;0&#8243;);<br />
WENN(REST(E2;4)&gt;=2;&#8221;1&#8243;;&#8221;0&#8243;);<br />
WENN(REST(E2;2)&gt;=1;&#8221;1&#8243;;&#8221;0&#8243;))</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Davies</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/12/02/decimal-to-binary/#comment-64619</link>
		<dc:creator>John Davies</dc:creator>
		<pubDate>Thu, 09 Jun 2011 22:06:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1292#comment-64619</guid>
		<description>&lt;p&gt;This won&#039;t handle negative numbers. It will handle anything up to VBA&#039;s maximum string length, but it takes its input number and returns the transformation as strings. The &quot;From&quot; and &quot;To&quot; bases are decimal numbers. Either base can be anything from 2 to 36. I&#039;m cutting &amp; pasting from something else, so I hope I get all that right! Error checking is done elsewhere in my code.&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container vb default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;vb codecolorer&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt; ChangeBase(&lt;span class=&quot;kw1&quot;&gt;ByVal&lt;/span&gt; sFrom &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;, _&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; sTo &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;, _&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;ByVal&lt;/span&gt; nFrom &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, _&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;ByVal&lt;/span&gt; nTo &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;) &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Boolean&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; Len(sFrom) = 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; sTo = &lt;span class=&quot;st0&quot;&gt;&quot;0&quot;&lt;/span&gt;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; bNonZero &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Boolean&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; i &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i = 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; Len(sFrom)&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; Mid$(sFrom, i, 1) &lt;&gt; &lt;span class=&quot;st0&quot;&gt;&quot;0&quot;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; bNonZero = &lt;span class=&quot;kw1&quot;&gt;True&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Exit&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039;Mid$(sFrom, i, 1) &lt;&gt; &quot;0&quot;&lt;br&gt;
&lt;/span&gt; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; i&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; bNonZero &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; sTo = &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Do&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039;Until Len(sFrom) = 0&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; Left$(sFrom, 1) = &lt;span class=&quot;st0&quot;&gt;&quot;0&quot;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; sFrom = Right$(sFrom, Len(sFrom) - 1)&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; nCarry &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; nCarry = 0&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i = 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; Len(sFrom)&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; nNum &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; CharToNum(Mid$(sFrom, i, 1), nNum) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; Err.Raise knCall, , ksCall&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; n &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; n = nFrom * nCarry + nNum&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; nCarry = n &lt;span class=&quot;kw1&quot;&gt;Mod&lt;/span&gt; nTo&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; sNum &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; NumToChar(n  nTo, sNum) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; Err.Raise knCall, , ksCall&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; Mid$(sFrom, i, 1) = sNum&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; i&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; NumToChar(nCarry, sNum) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; Err.Raise knCall, , ksCall&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; sTo = sNum &amp; sTo&lt;br&gt;
&#160; &#160; &#160; &#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039;Left$(sFrom, 1) = &quot;0&quot;&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;Loop&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Until&lt;/span&gt; Len(sFrom) = 0&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; sTo = sFrom &lt;span class=&quot;co1&quot;&gt;&#039;All zeros&lt;br&gt;
&lt;/span&gt; &#160; &#160;&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039;bNonZero&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;&#039;Len(sFrom) = 0&lt;br&gt;
&lt;/span&gt;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt; CharToNum(s &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;, n &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;) &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Boolean&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; IsNumeric(s) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; n = &lt;span class=&quot;kw1&quot;&gt;CLng&lt;/span&gt;(s)&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;&lt;br&gt;
&#160; &#160; n = Asc(s) - 55&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt; NumToChar(n &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;, s &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;) &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Boolean&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; n &lt; 10 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; s = &lt;span class=&quot;kw1&quot;&gt;CStr&lt;/span&gt;(n)&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;&lt;br&gt;
&#160; &#160; s = Chr$(55 + n)&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;&lt;br&gt;
&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
</description>
		<content:encoded><![CDATA[<p>This won&#8217;t handle negative numbers. It will handle anything up to VBA&#8217;s maximum string length, but it takes its input number and returns the transformation as strings. The &#8220;From&#8221; and &#8220;To&#8221; bases are decimal numbers. Either base can be anything from 2 to 36. I&#8217;m cutting &amp; pasting from something else, so I hope I get all that right! Error checking is done elsewhere in my code.</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">Function</span> ChangeBase(<span class="kw1">ByVal</span> sFrom <span class="kw1">As</span> <span class="kw1">String</span>, _<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sTo <span class="kw1">As</span> <span class="kw1">String</span>, _<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">ByVal</span> nFrom <span class="kw1">As</span> <span class="kw1">Long</span>, _<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">ByVal</span> nTo <span class="kw1">As</span> <span class="kw1">Long</span>) <span class="kw1">As</span> <span class="kw1">Boolean</span></p>
<p><span class="kw1">If</span> Len(sFrom) = 0 <span class="kw1">Then</span><br />
&nbsp; &nbsp; sTo = <span class="st0">&#8220;0&#8243;</span><br />
<span class="kw1">Else</span><br />
&nbsp; &nbsp; <span class="kw1">Dim</span> bNonZero <span class="kw1">As</span> <span class="kw1">Boolean</span><br />
&nbsp; &nbsp; <span class="kw1">Dim</span> i <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; &nbsp; <span class="kw1">For</span> i = 1 <span class="kw1">To</span> Len(sFrom)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> Mid$(sFrom, i, 1) &lt;&gt; <span class="st0">&#8220;0&#8243;</span> <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bNonZero = <span class="kw1">True</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Exit</span> <span class="kw1">For</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span> <span class="co1">&#8216;Mid$(sFrom, i, 1) &lt;&gt; &#8220;0&#8243;<br />
</span> &nbsp; &nbsp;<span class="kw1">Next</span> i<br />
&nbsp; &nbsp; <span class="kw1">If</span> bNonZero <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sTo = <span class="st0">&#8220;&#8221;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Do</span> <span class="co1">&#8216;Until Len(sFrom) = 0<br />
</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">If</span> Left$(sFrom, 1) = <span class="st0">&#8220;0&#8243;</span> <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sFrom = Right$(sFrom, Len(sFrom) &#8211; 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Dim</span> nCarry <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nCarry = 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">For</span> i = 1 <span class="kw1">To</span> Len(sFrom)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Dim</span> nNum <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> CharToNum(Mid$(sFrom, i, 1), nNum) <span class="kw1">Then</span> Err.Raise knCall, , ksCall<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Dim</span> n <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n = nFrom * nCarry + nNum<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nCarry = n <span class="kw1">Mod</span> nTo<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Dim</span> sNum <span class="kw1">As</span> <span class="kw1">String</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> NumToChar(n  nTo, sNum) <span class="kw1">Then</span> Err.Raise knCall, , ksCall<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Mid$(sFrom, i, 1) = sNum<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Next</span> i<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> NumToChar(nCarry, sNum) <span class="kw1">Then</span> Err.Raise knCall, , ksCall<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sTo = sNum &amp; sTo<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span> <span class="co1">&#8216;Left$(sFrom, 1) = &#8220;0&#8243;<br />
</span> &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Loop</span> <span class="kw1">Until</span> Len(sFrom) = 0<br />
&nbsp; &nbsp; <span class="kw1">Else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sTo = sFrom <span class="co1">&#8216;All zeros<br />
</span> &nbsp; &nbsp;<span class="kw1">End</span> <span class="kw1">If</span> <span class="co1">&#8216;bNonZero<br />
</span><span class="kw1">End</span> <span class="kw1">If</span> <span class="co1">&#8216;Len(sFrom) = 0<br />
</span><br />
<span class="kw1">End</span> <span class="kw1">Function</span></p>
<p><span class="kw1">Function</span> CharToNum(s <span class="kw1">As</span> <span class="kw1">String</span>, n <span class="kw1">As</span> <span class="kw1">Long</span>) <span class="kw1">As</span> <span class="kw1">Boolean</span></p>
<p><span class="kw1">If</span> IsNumeric(s) <span class="kw1">Then</span><br />
&nbsp; &nbsp; n = <span class="kw1">CLng</span>(s)<br />
<span class="kw1">Else</span><br />
&nbsp; &nbsp; n = Asc(s) &#8211; 55<br />
<span class="kw1">End</span> <span class="kw1">If</span></p>
<p><span class="kw1">End</span> <span class="kw1">Function</span></p>
<p><span class="kw1">Function</span> NumToChar(n <span class="kw1">As</span> <span class="kw1">Long</span>, s <span class="kw1">As</span> <span class="kw1">String</span>) <span class="kw1">As</span> <span class="kw1">Boolean</span></p>
<p><span class="kw1">If</span> n &lt; 10 <span class="kw1">Then</span><br />
&nbsp; &nbsp; s = <span class="kw1">CStr</span>(n)<br />
<span class="kw1">Else</span><br />
&nbsp; &nbsp; s = Chr$(55 + n)<br />
<span class="kw1">End</span> <span class="kw1">If</span></p>
<p><span class="kw1">End</span> <span class="kw1">Function</span></div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: fatbrainslim</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/12/02/decimal-to-binary/#comment-61937</link>
		<dc:creator>fatbrainslim</dc:creator>
		<pubDate>Fri, 08 Apr 2011 14:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1292#comment-61937</guid>
		<description>&lt;p&gt;sorry for my missed post to the wrong place, my below formular is for convert subnet mask to number of mask bit such as 255.255.255.0 to /24&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container text default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;text codecolorer&quot;&gt;=FIND(&quot;0&quot;,CONCATENATE(DEC2BIN(LEFT(c3,FIND(&quot;.&quot;,c3)-1)),DEC2BIN(MID(c3,FIND(&quot;.&quot;,c3)+1,FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3)+1)-FIND(&quot;.&quot;,c3)-1)),DEC2BIN(MID(c3,FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3)+1)+1,FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3)+1)+1)-FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3)+1)-1)),DEC2BIN(RIGHT(c3,LEN(c3)-FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3)+1)+1))),&quot;0&quot;))-1&lt;/div&gt;&lt;/div&gt;
</description>
		<content:encoded><![CDATA[<p>sorry for my missed post to the wrong place, my below formular is for convert subnet mask to number of mask bit such as 255.255.255.0 to /24</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container text default">
<div style="white-space: nowrap;" class="text codecolorer">=FIND(&#8220;0&#8243;,CONCATENATE(DEC2BIN(LEFT(c3,FIND(&#8220;.&#8221;,c3)-1)),DEC2BIN(MID(c3,FIND(&#8220;.&#8221;,c3)+1,FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3)+1)-FIND(&#8220;.&#8221;,c3)-1)),DEC2BIN(MID(c3,FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3)+1)+1,FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3)+1)+1)-FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3)+1)-1)),DEC2BIN(RIGHT(c3,LEN(c3)-FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3)+1)+1))),&#8221;0&#8243;))-1</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: fatbrainslim</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/12/02/decimal-to-binary/#comment-61936</link>
		<dc:creator>fatbrainslim</dc:creator>
		<pubDate>Fri, 08 Apr 2011 14:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1292#comment-61936</guid>
		<description>&lt;p&gt;try this....&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container text default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;text codecolorer&quot;&gt;=FIND(&quot;0&quot;,CONCATENATE(DEC2BIN(LEFT(c3,FIND(&quot;.&quot;,c3)-1)),DEC2BIN(MID(c3,FIND(&quot;.&quot;,c3)+1,FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3)+1)-FIND(&quot;.&quot;,c3)-1)),DEC2BIN(MID(c3,FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3)+1)+1,FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3)+1)+1)-FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3)+1)-1)),DEC2BIN(RIGHT(c3,LEN(c3)-FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3,FIND(&quot;.&quot;,c3)+1)+1))),&quot;0&quot;))-1&lt;/div&gt;&lt;/div&gt;
</description>
		<content:encoded><![CDATA[<p>try this&#8230;.</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container text default">
<div style="white-space: nowrap;" class="text codecolorer">=FIND(&#8220;0&#8243;,CONCATENATE(DEC2BIN(LEFT(c3,FIND(&#8220;.&#8221;,c3)-1)),DEC2BIN(MID(c3,FIND(&#8220;.&#8221;,c3)+1,FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3)+1)-FIND(&#8220;.&#8221;,c3)-1)),DEC2BIN(MID(c3,FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3)+1)+1,FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3)+1)+1)-FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3)+1)-1)),DEC2BIN(RIGHT(c3,LEN(c3)-FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3,FIND(&#8220;.&#8221;,c3)+1)+1))),&#8221;0&#8243;))-1</div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Rothstein (MVP - Excel)</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/12/02/decimal-to-binary/#comment-53283</link>
		<dc:creator>Rick Rothstein (MVP - Excel)</dc:creator>
		<pubDate>Wed, 27 Oct 2010 21:50:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1292#comment-53283</guid>
		<description>&lt;p&gt;Sorry, I forgot the &quot;code tags&quot;... I just noticed some of my lines have been corrupted. Here is my code again, but this time using the &quot;code tags&quot;...&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container vb default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;vb codecolorer&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt; DecToBin(&lt;span class=&quot;kw1&quot;&gt;ByVal&lt;/span&gt; DecimalIn &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;, &lt;span class=&quot;kw1&quot;&gt;Optional&lt;/span&gt; NumberOfBits &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt; = 0) &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; DecimalIn &lt; 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160;Negative values cannot be converted&lt;br&gt;
&lt;/span&gt; &#160; &#160;DecToBin = CVErr(xlErrValue)&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Exit&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;&lt;br&gt;
&#160; &#160; DecimalIn = Int(&lt;span class=&quot;kw1&quot;&gt;CDec&lt;/span&gt;(DecimalIn))&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Do&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;While&lt;/span&gt; DecimalIn &lt;&gt; 0&lt;br&gt;
&#160; &#160; &#160; DecToBin = Trim$(Str$(DecimalIn - 2 * Int(DecimalIn / 2))) &amp; DecToBin&lt;br&gt;
&#160; &#160; &#160; DecimalIn = Int(DecimalIn / 2)&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Loop&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; NumberOfBits &gt; 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; Len(DecToBin) &gt; NumberOfBits &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; &lt;span class=&quot;co1&quot;&gt;&#039; &#160;Calculated value exceeds specified bit size&lt;br&gt;
&lt;/span&gt; &#160; &#160; &#160; &#160;DecToBin = CVErr(xlErrValue)&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;&lt;br&gt;
&#160; &#160; &#160; &#160; DecToBin = Right$(&lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;$(NumberOfBits, &lt;span class=&quot;st0&quot;&gt;&quot;0&quot;&lt;/span&gt;) &amp; DecToBin, NumberOfBits)&lt;br&gt;
&#160; &#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;&lt;br&gt;
&#160; &#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;&lt;br&gt;
&#160; &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
</description>
		<content:encoded><![CDATA[<p>Sorry, I forgot the &#8220;code tags&#8221;&#8230; I just noticed some of my lines have been corrupted. Here is my code again, but this time using the &#8220;code tags&#8221;&#8230;</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">Function</span> DecToBin(<span class="kw1">ByVal</span> DecimalIn <span class="kw1">As</span> <span class="kw1">Variant</span>, <span class="kw1">Optional</span> NumberOfBits <span class="kw1">As</span> <span class="kw1">Variant</span> = 0) <span class="kw1">As</span> <span class="kw1">Variant</span><br />
&nbsp; <span class="kw1">If</span> DecimalIn &lt; 0 <span class="kw1">Then</span><br />
&nbsp; &nbsp; <span class="co1">&#8216; &nbsp;Negative values cannot be converted<br />
</span> &nbsp; &nbsp;DecToBin = CVErr(xlErrValue)<br />
&nbsp; &nbsp; <span class="kw1">Exit</span> <span class="kw1">Function</span><br />
&nbsp; <span class="kw1">Else</span><br />
&nbsp; &nbsp; DecimalIn = Int(<span class="kw1">CDec</span>(DecimalIn))<br />
&nbsp; &nbsp; <span class="kw1">Do</span> <span class="kw1">While</span> DecimalIn &lt;&gt; 0<br />
&nbsp; &nbsp; &nbsp; DecToBin = Trim$(Str$(DecimalIn &#8211; 2 * Int(DecimalIn / 2))) &amp; DecToBin<br />
&nbsp; &nbsp; &nbsp; DecimalIn = Int(DecimalIn / 2)<br />
&nbsp; &nbsp; <span class="kw1">Loop</span><br />
&nbsp; &nbsp; <span class="kw1">If</span> NumberOfBits &gt; 0 <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">If</span> Len(DecToBin) &gt; NumberOfBits <span class="kw1">Then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#8216; &nbsp;Calculated value exceeds specified bit size<br />
</span> &nbsp; &nbsp; &nbsp; &nbsp;DecToBin = CVErr(xlErrValue)<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">Else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; DecToBin = Right$(<span class="kw1">String</span>$(NumberOfBits, <span class="st0">&#8220;0&#8243;</span>) &amp; DecToBin, NumberOfBits)<br />
&nbsp; &nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span><br />
&nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span><br />
&nbsp; <span class="kw1">End</span> <span class="kw1">If</span><br />
<span class="kw1">End</span> <span class="kw1">Function</span></div>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Rothstein (MVP - Excel)</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/12/02/decimal-to-binary/#comment-53281</link>
		<dc:creator>Rick Rothstein (MVP - Excel)</dc:creator>
		<pubDate>Wed, 27 Oct 2010 21:39:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1292#comment-53281</guid>
		<description>&lt;p&gt;While this function (which works fine as a UDF) only handles positive values, it will return the Binary string for values up to 9999999999999999999999999999. I&#039;m thinking that should be a large enough range to handle whatever you may want to throw at it. If the value you want to process is larger than Excel can properly handle as whole number, simply pass the value in as text. So, for the maximum value the function can handle, you would call it like this from VB...&lt;/p&gt;
&lt;p&gt;MsgBox DecToBin(&quot;9999999999999999999999999999?)&lt;/p&gt;
&lt;p&gt;or like this from the worksheet...&lt;/p&gt;
&lt;p&gt;=DecToBin(&quot;9999999999999999999999999999?)&lt;/p&gt;
&lt;p&gt;or, if A1 contains &#039;9999999999999999999999999999 (note the leading apostrophe) or 9999999999999999999999999999 if formatted as Text, then like this...&lt;/p&gt;
&lt;p&gt;=DecToBin(A1)&lt;/p&gt;
&lt;p&gt;Okay, here is the function (note that the Analysis ToolPak has a similarly named function which uses a &quot;2? to link the words &quot;Dec&quot; and &quot;Bin&quot; instead of the word &quot;To&quot; that my function does)...&lt;/p&gt;
&lt;p&gt;Function DecToBin(ByVal DecimalIn As Variant, Optional NumberOfBits As Variant = 0) As Variant&lt;br&gt;
  If DecimalIn &lt; 0 Then&lt;br&gt;
    &#039;  Negative values cannot be converted&lt;br&gt;
    DecToBin = CVErr(xlErrValue)&lt;br&gt;
    Exit Function&lt;br&gt;
  Else&lt;br&gt;
    DecimalIn = Int(CDec(DecimalIn))&lt;br&gt;
    Do While DecimalIn  0&lt;br&gt;
      DecToBin = Trim$(Str$(DecimalIn - 2 * Int(DecimalIn / 2))) &amp; DecToBin&lt;br&gt;
      DecimalIn = Int(DecimalIn / 2)&lt;br&gt;
    Loop&lt;br&gt;
    If NumberOfBits &gt; 0 Then&lt;br&gt;
      If Len(DecToBin) &gt; NumberOfBits Then&lt;br&gt;
        &#039;  Calculated value exceeds specified bit size&lt;br&gt;
        DecToBin = CVErr(xlErrValue)&lt;br&gt;
      Else&lt;br&gt;
        DecToBin = Right$(String$(NumberOfBits, &quot;0?) &amp; DecToBin, NumberOfBits)&lt;br&gt;
      End If&lt;br&gt;
    End If&lt;br&gt;
  End If&lt;br&gt;
End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>While this function (which works fine as a UDF) only handles positive values, it will return the Binary string for values up to 9999999999999999999999999999. I&#8217;m thinking that should be a large enough range to handle whatever you may want to throw at it. If the value you want to process is larger than Excel can properly handle as whole number, simply pass the value in as text. So, for the maximum value the function can handle, you would call it like this from VB&#8230;</p>
<p>MsgBox DecToBin(&#8220;9999999999999999999999999999?)</p>
<p>or like this from the worksheet&#8230;</p>
<p>=DecToBin(&#8220;9999999999999999999999999999?)</p>
<p>or, if A1 contains &#8217;9999999999999999999999999999 (note the leading apostrophe) or 9999999999999999999999999999 if formatted as Text, then like this&#8230;</p>
<p>=DecToBin(A1)</p>
<p>Okay, here is the function (note that the Analysis ToolPak has a similarly named function which uses a &#8220;2? to link the words &#8220;Dec&#8221; and &#8220;Bin&#8221; instead of the word &#8220;To&#8221; that my function does)&#8230;</p>
<p>Function DecToBin(ByVal DecimalIn As Variant, Optional NumberOfBits As Variant = 0) As Variant<br />
  If DecimalIn &lt; 0 Then<br />
    &#8216;  Negative values cannot be converted<br />
    DecToBin = CVErr(xlErrValue)<br />
    Exit Function<br />
  Else<br />
    DecimalIn = Int(CDec(DecimalIn))<br />
    Do While DecimalIn  0<br />
      DecToBin = Trim$(Str$(DecimalIn &#8211; 2 * Int(DecimalIn / 2))) &amp; DecToBin<br />
      DecimalIn = Int(DecimalIn / 2)<br />
    Loop<br />
    If NumberOfBits &gt; 0 Then<br />
      If Len(DecToBin) &gt; NumberOfBits Then<br />
        &#8216;  Calculated value exceeds specified bit size<br />
        DecToBin = CVErr(xlErrValue)<br />
      Else<br />
        DecToBin = Right$(String$(NumberOfBits, &#8220;0?) &amp; DecToBin, NumberOfBits)<br />
      End If<br />
    End If<br />
  End If<br />
End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: User</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/12/02/decimal-to-binary/#comment-53135</link>
		<dc:creator>User</dc:creator>
		<pubDate>Mon, 25 Oct 2010 16:47:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1292#comment-53135</guid>
		<description>&lt;p&gt;Excellent code. Works great! Thanks.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Excellent code. Works great! Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xyz</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/12/02/decimal-to-binary/#comment-36931</link>
		<dc:creator>xyz</dc:creator>
		<pubDate>Wed, 07 Jan 2009 10:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1292#comment-36931</guid>
		<description>&lt;p&gt;Use this formula to convert the Binary(10100111000000) number in cell G19 to decimal number.&lt;/p&gt;
&lt;p&gt;=SUMPRODUCT(2^(ROW(INDIRECT(&quot;1:&quot;&amp;LEN(G7)))-1),VALUE(MID(G7,LEN(G7)-ROW(INDIRECT(&quot;1:&quot;&amp;LEN(G7)))+1,1)))&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Use this formula to convert the Binary(10100111000000) number in cell G19 to decimal number.</p>
<p>=SUMPRODUCT(2^(ROW(INDIRECT(&#8220;1:&#8221;&amp;LEN(G7)))-1),VALUE(MID(G7,LEN(G7)-ROW(INDIRECT(&#8220;1:&#8221;&amp;LEN(G7)))+1,1)))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GuM</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/12/02/decimal-to-binary/#comment-34903</link>
		<dc:creator>GuM</dc:creator>
		<pubDate>Mon, 29 Sep 2008 09:20:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1292#comment-34903</guid>
		<description>&lt;p&gt;another try...&lt;/p&gt;
&lt;p&gt;&lt;code lang=&quot;vb&quot;&gt;&lt;br&gt;
Function Long2Bin(lNumber As Long, Optional lPlaces As Long = 8) As String&lt;br&gt;
    &#039; converts a decimal number to a binary string&lt;/code&gt;&lt;/p&gt;
&lt;code lang=&quot;vb&quot;&gt;
&lt;p&gt;    Static vDigits As Variant           &#039; digits used in the result string&lt;/p&gt;
&lt;p&gt;    Dim lVal As Long                    &#039; temporary value&lt;br&gt;
    Dim sTemp As String                 &#039; to build up the result string&lt;/p&gt;
&lt;p&gt;    &#039; init digits on first call of function&lt;br&gt;
    If IsEmpty(vDigits) Then vDigits = Array(&quot;0&quot;, &quot;1&quot;)&lt;/p&gt;
&lt;p&gt;    &#039; corrections for negative numbers&lt;br&gt;
    lVal = Abs(lNumber)                 &#039; always work on positive numbers&lt;br&gt;
    If lNumber  0) Or (lPlaces &gt; 0)&lt;br&gt;
        sTemp = vDigits(lVal Mod 2) &amp; sTemp &#039; add char in front of string&lt;br&gt;
        lPlaces = lPlaces - 1&lt;br&gt;
        lVal = lVal  2                 &#039; integer division by 2&lt;br&gt;
    Loop&lt;/p&gt;
&lt;p&gt;    &#039; one&#039;s complement for negative numbers&lt;br&gt;
    If lNumber&lt;/p&gt;&lt;/code&gt;
&lt;p&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>another try&#8230;</p>
<p><div class="codecolorer-container vb default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;br&gt;<br />
<span style="color: #E56717; font-weight: bold;">Function</span> Long2Bin(lNumber <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Long</span>, <span style="color: #151B8D; font-weight: bold;">Optional</span> lPlaces <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Long</span> = 8) <span style="color: #151B8D; font-weight: bold;">As</span> String&lt;br&gt;<br />
&nbsp; &nbsp; ' converts a <span style="color: #F660AB; font-weight: bold;">decimal</span> number <span style="color: #8D38C9; font-weight: bold;">to</span> a <span style="color: #F660AB; font-weight: bold;">binary</span> <span style="color: #F660AB; font-weight: bold;">string</span></div></div>
</p>
<div class="codecolorer-container vb default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="vb codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;p&gt; &nbsp; &nbsp;<span style="color: #151B8D; font-weight: bold;">Static</span> vDigits <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Variant</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">' digits used in the result string&lt;/p&gt;<br />
</span>&lt;p&gt; &nbsp; &nbsp;<span style="color: #151B8D; font-weight: bold;">Dim</span> lVal <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Long</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000;">' temporary value&lt;br&gt;<br />
</span> &nbsp; &nbsp;<span style="color: #151B8D; font-weight: bold;">Dim</span> sTemp <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">' to build up the result string&lt;/p&gt;<br />
</span>&lt;p&gt; &nbsp; &nbsp;<span style="color: #008000;">' init digits on first call of function&lt;br&gt;<br />
</span> &nbsp; &nbsp;<span style="color: #8D38C9; font-weight: bold;">If</span> IsEmpty(vDigits) <span style="color: #8D38C9; font-weight: bold;">Then</span> vDigits = Array(<span style="color: #800000;">&quot;0&quot;</span>, <span style="color: #800000;">&quot;1&quot;</span>)&lt;/p&gt;<br />
&lt;p&gt; &nbsp; &nbsp;<span style="color: #008000;">' corrections for negative numbers&lt;br&gt;<br />
</span> &nbsp; &nbsp;lVal = Abs(lNumber) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">' always work on positive numbers&lt;br&gt;<br />
</span> &nbsp; &nbsp;<span style="color: #8D38C9; font-weight: bold;">If</span> lNumber &nbsp;0) <span style="color: #8D38C9; font-weight: bold;">Or</span> (lPlaces &amp;gt; 0)&lt;br&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; sTemp = vDigits(lVal <span style="color: #151B8D; font-weight: bold;">Mod</span> 2) &amp;amp; sTemp <span style="color: #008000;">' add char in front of string&lt;br&gt;<br />
</span> &nbsp; &nbsp; &nbsp; &nbsp;lPlaces = lPlaces - 1&lt;br&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; lVal = lVal &nbsp;2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">' integer division by 2&lt;br&gt;<br />
</span> &nbsp; &nbsp;Loop&lt;/p&gt;<br />
&lt;p&gt; &nbsp; &nbsp;<span style="color: #008000;">' one's complement for negative numbers&lt;br&gt;<br />
</span> &nbsp; &nbsp;<span style="color: #8D38C9; font-weight: bold;">If</span> lNumber&lt;/p&gt;</div></div></p>
]]></content:encoded>
	</item>
</channel>
</rss>

