<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>nandeshwar.info &#187; VBA</title>
	<atom:link href="http://nandeshwar.info/tag/vba/feed/" rel="self" type="application/rss+xml" />
	<link>http://nandeshwar.info</link>
	<description></description>
	<lastBuildDate>Mon, 12 Dec 2011 21:33:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>My experiments with sparklines</title>
		<link>http://nandeshwar.info/2009/09/23/my-experiments-with-sparklines/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-experiments-with-sparklines</link>
		<comments>http://nandeshwar.info/2009/09/23/my-experiments-with-sparklines/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 18:05:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Access]]></category>
		<category><![CDATA[dashboard]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[LaTex]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[sparklines]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://nandeshwar.info/?p=293</guid>
		<description><![CDATA[For the uninitiated, Sparklines are &#8220;data-intense, design-simple, word-sized graphics&#8221; according to its inventor Edward Tufte. I always wanted to include them in my trend reports. The challenge: How and Which tool to use? The data came from this report came from a complex query using SQL server and Access that had this format: College Major [...]]]></description>
			<content:encoded><![CDATA[<p>For the uninitiated, <a title="Sparkline" href="http://en.wikipedia.org/wiki/Sparkline">Sparklines</a> are &#8220;data-intense, design-simple, word-sized graphics&#8221; according to its inventor <a title="Edward Tufte" href="http://en.wikipedia.org/wiki/Edward_Tufte">Edward Tufte</a>. I always wanted to include them in my trend reports. The challenge: How and Which tool to use?</p>
<p>The data came from this report came from a complex query using SQL server and Access that had this format:</p>
<table border="0">
<tbody>
<tr>
<td>College</td>
<td>Major</td>
<td>2005</td>
<td>2006</td>
<td>2007</td>
<td>2008</td>
<td>2009</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>10</td>
<td>15</td>
<td>14</td>
<td>18</td>
<td>25</td>
</tr>
</tbody>
</table>
<p>Some options I investigated and tried (be sure to read <a href="http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0000Lk">this page</a>, you might find many more):</p>
<ul>
<li>Google&#8217;s Chart API (<a href="http://code.google.com/apis/chart/types.html">http://code.google.com/apis/chart/types.html</a>): you can embed these in Google spreadsheets,  create HTML pages using <a href="http://www.cazh1.com/blogger/thoughts/2009/01/hacking-google-chart-api-from-excel.shtml">Excel via VBA</a>, or embed them in<a href="http://www.tushar-mehta.com/publish_train/xl_vba_cases/excel_google_chart_api/index.htm"> Excel sheets</a>. Alas, none would work the way I would like them to work: In-cell graphics</li>
<li> <a href="http://sparklines-excel.blogspot.com/">Use Sparklines for Excel add-in</a>: this add-in will create great in-cell charts (bar, bullet graphs, sparklines, etc), but copying them down is difficult and resource intensive, and any change you make in the column size will alter the shape of that chart. In addition, I had more than 400 rows to populate&#8211;these would be too many objects in a spreadsheet for Excel to handle. My machine froze when I tried to copy it for 10 rows.</li>
<li>Use R&#8217;s implementation by Jason Dieterle (search on <a href="http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0000Lk">this page</a> for Jason Dieterle (email), January 28, 2008. Works very good. I modified the code to print max and mins only, but the function generates a graphic, which needed to be embeded in LaTex file. It did not work nicely. Charts were too big to fit in a cell of a table.</li>
<li>Create bar charts in <a href="http://www.juiceanalytics.com/writing/lightweight-data-exploration-in-excel/">Excel using REPT function</a>. I tried different font sizes and styles, but it didn&#8217;t look pretty, for the range of data varied. (Hint: make the alignment of text 90, use pipe signs, create columns and graphs for each data value, remove gridlines, keep the columns very close. It almost worked.)</li>
<li>Use <a href="http://jblevins.org/projects/spark/">spark</a> package for LaTex, doesn&#8217;t work in pdflatex, and you have to play a lot with the settings</li>
<li>Use <a href="http://www.ctan.org/tex-archive/help/Catalogue/entries/sparklines.html">sparklines </a>package for LaTex. Problem was that data needed to be normalized (or scaled) from 0 to 1, and needed extra parameters for min and max points. Solution: create a normalize function in Excel, and write a big formula to produce the exact needed string for the sparklines to work i.e.:<br />
<code>\begin{sparkline}{5}<br />
\sparkdot 1 1 blue<br />
\sparkdot 0.2 0 red<br />
\spark 0.2 0 0.4 0.0625 0.6 0.5625 0.8 0.75 1 1 /<br />
\end{sparkline}</code></li>
</ul>
<p>Here&#8217;s the normalize function:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Public</span> <span style="color: #000080;">Function</span> Normalize(cell2Normalize <span style="color: #000080;">As</span> Range, WholeRng <span style="color: #000080;">As</span> Range)
       Normalize = (cell2Normalize.Value - WorksheetFunction.Min(WholeRng)) / (WorksheetFunction.Max(WholeRng) - WorksheetFunction.Min(WholeRng))
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<p>Here&#8217;s the big formula to convert the range for data values from 2005 to 2009 (in the range E2:I2) to the sparkline LaTex environment.<br />
<code><br />
="\begin{sparkline}{5} " &amp; "\sparkdot " &amp; CHOOSE(MATCH(MAX(E2:I2),E2:I2,0),0.2,0.4,0.6,0.8,1) &amp; " " &amp; 1 &amp; " blue " &amp; "\sparkdot " &amp; CHOOSE(MATCH(MIN(E2:I2),E2:I2,0),0.2,0.4,0.6,0.8,1) &amp; " " &amp; 0 &amp; " red " &amp; " \spark 0.2 " &amp; Normalize(E2,E2:I2) &amp; " 0.4 " &amp; Normalize(F2,E2:I2) &amp; " 0.6 " &amp; Normalize(G2,E2:I2) &amp; " 0.8 " &amp; Normalize(H2,E2:I2) &amp; " 1 " &amp; Normalize(I2,E2:I2) &amp; " / \end{sparkline}"</code></p>
<p>This last option worked beautifully. I dragged the formula down. I selected the data, and clicked on &#8220;Convert Table to LaTex&#8221; button (using this<a href="http://dataninja.wordpress.com/2006/01/20/excel-to-latex/"> add-in</a>). Copied the LaTex code to clipboard and pasted it in my LaTex editor. Manually merged the rows for colleges (using \multirow), and generated a beautiful looking pdf.</p>
<p>I was very happy. Printed it in color. Got a request back very soon that there should be total rows.</p>
<p>I forgot about the sparklines and created a report in Access with plain old numbers in less than 15 mins. Gave it back.</p>
<p>I tried to repeat this &#8211; <a href="http://www.youtube.com/watch?v=EK73YYo0CUk">Sparkline in Cognos</a> -in Access with no luck.</p>
<p>(I later tried it one more time: Got the data in Excel using External data&gt; Access, created a pivottable with rows and all, did some formatting, copied and pasted values and formats, inserted sparkline code, converted it to LaTex, copied and pasted in LaTex editor, and here&#8217;s the beautiful looking <a href="http://nandeshwar.info/wp-content/uploads/2009/09/CollegeEnrSample.pdf">sample pdf</a> of 16)</p>
<p>I wish there were simple reporting solutions that included awesome data visualization tools. (BTW, Excel 2010 will have sparklines: <a href="http://blogs.msdn.com/excel/archive/2009/07/17/sparklines-in-excel.aspx">link</a>) For this report, I did try Sweave, R, and LaTex, but because of the time constraints I could not investigate it further.</p>
<p>Please comment if you know any other way which meet (or don&#8217;t, Tableau is certainly one) these conditions: inexpensive (read free), efficient,  and repeatable.</p>
]]></content:encoded>
			<wfw:commentRss>http://nandeshwar.info/2009/09/23/my-experiments-with-sparklines/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Access to the VB project is not trusted</title>
		<link>http://nandeshwar.info/2009/04/24/access-to-the-vb-project-is-not-trusted/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=access-to-the-vb-project-is-not-trusted</link>
		<comments>http://nandeshwar.info/2009/04/24/access-to-the-vb-project-is-not-trusted/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 14:42:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Error messages]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://nandeshwar.info/?p=197</guid>
		<description><![CDATA[I was trying to enable an add-in for Excel 2007, and I kept getting this error: Access to the VB project is not trusted You can turn this message off by going to Developer tab in the ribbon and then clicking on the Macro security button, and checking the check box for &#8220;Trust access to [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to enable an add-in for Excel 2007, and I kept getting this error:</p>
<blockquote><p>Access to the VB project is not trusted</p></blockquote>
<p>You can turn this message off by going to Developer tab in the ribbon and then clicking on the Macro security button, and checking the check box for &#8220;Trust access to the VBA project object model.&#8221;</p>
<p>A word of caution: be wary of the add-ins/projects that need VBA access. Don&#8217;t allow any project/add-in with VBA access, unless you know its exact purpose or the author of that project.</p>
]]></content:encoded>
			<wfw:commentRss>http://nandeshwar.info/2009/04/24/access-to-the-vb-project-is-not-trusted/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Student&#8217;s t-test for equal means</title>
		<link>http://nandeshwar.info/2008/10/29/students-t-test-for-equal-means/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=students-t-test-for-equal-means</link>
		<comments>http://nandeshwar.info/2008/10/29/students-t-test-for-equal-means/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 13:06:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[String Operations]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Useful Procedures]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[UDF]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://a7n9.wordpress.com/2008/10/29/students-t-test-for-equal-means/</guid>
		<description><![CDATA[If you do not wish to enter complex formula in Excel and you already have calculated average, count, and variance for your samples(Tip:use a PivotTable), then you can use these user-defined functions to calculate the t-test stat value and degrees of freedom required to do hypothesis testing. Both the functions provide an optional argument for [...]]]></description>
			<content:encoded><![CDATA[<p>If you do not wish to enter complex formula in Excel and you already have calculated average, count, and variance for your samples(Tip:use a PivotTable), then you can use these user-defined functions to calculate the t-test stat value and degrees of freedom required to do hypothesis testing. Both the functions provide an optional argument for the assumption of equal variances; by default it is set to false.</p>
<p>Here&#8217;s the code for t-test:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">'---------------------------------------------------------------------------------------
</span><span style="color: #008000;">' Procedure : TTESTM
</span><span style="color: #008000;">' DateTime  : 10/29/2008 08:35
</span><span style="color: #008000;">' Author    :
</span><span style="color: #008000;">' Purpose   : To get the t-stat value when comparing two means with an optional input
</span><span style="color: #008000;">'               for equal or unequal variances
</span><span style="color: #008000;">'               by default the function assumes that the user is comparing means with unequal variances
</span><span style="color: #008000;">' davg1 is the mean of first sample
</span><span style="color: #008000;">' dcnt1 is the sample size of sample 1 
</span><span style="color: #008000;">' dvar1 is the variance of first samaple 
</span><span style="color: #008000;">' davg2 is the mean of second sample
</span><span style="color: #008000;">' dcnt2 is the sample size of sample 2 
</span><span style="color: #008000;">' dvar2 is the variance of second samaple 
</span><span style="color: #008000;">' blnEqVar set TRUE to assume equal variance for the test
</span><span style="color: #008000;">'---------------------------------------------------------------------------------------
</span>
<span style="color: #000080;">Public</span> <span style="color: #000080;">Function</span> TTESTM(davg1 <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, dcnt1 <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, dvar1 <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, davg2 <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, dcnt2 <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, dvar2 <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, <span style="color: #000080;">Optional</span> blnEqVar <span style="color: #000080;">As</span> <span style="color: #000080;">Boolean</span> = <span style="color: #000080;">False</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>
&nbsp;
<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">GoTo</span> TTESTM_Error
<span style="color: #000080;">Dim</span> dResult <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, dNumer <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, dDenon <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, dPooledVar <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>
&nbsp;
dNumer = davg1 - davg2
&nbsp;
<span style="color: #008000;">'if equal variances are not assumed
</span><span style="color: #008000;">'http://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm
</span><span style="color: #000080;">If</span> <span style="color: #000080;">Not</span> blnEqVar <span style="color: #000080;">Then</span>
	dDenon = Sqr((dvar1 ^ 2 / dcnt1) + (dvar2 ^ 2 / dcnt2))
<span style="color: #000080;">Else</span>
<span style="color: #008000;">'if equal variances are assumed, then calculated the pooled variance
</span>	dPooledVar = Sqr((((dcnt1 - 1) * dvar1 ^ 2) + ((dcnt2 - 1) * dvar2 ^ 2)) / (dcnt1 + dcnt2 - 2))
	dDenon = dPooledVar * Sqr((1 / dcnt1) + (1 / dcnt2))
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
dResult = dNumer / dDenon
&nbsp;
TTESTM = dResult
<span style="color: #000080;">Exit</span> <span style="color: #000080;">Function</span>
&nbsp;
TTESTM_Error:
	TTESTM = Null
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<p>Code for degrees of freedom</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">'---------------------------------------------------------------------------------------
</span><span style="color: #008000;">' Procedure : DOFTTESTM
</span><span style="color: #008000;">' DateTime  : 10/29/2008 08:50
</span><span style="color: #008000;">' Author    :
</span><span style="color: #008000;">' Purpose   : To get the degrees of freedom for the t-test when comparing two means with an optional input
</span><span style="color: #008000;">'               for equal or unequal variances
</span><span style="color: #008000;">'               by default the function assumes that the user is comparing means with unequal variances
</span>
<span style="color: #008000;">' dcnt1 is the sample size of sample 1 
</span><span style="color: #008000;">' dvar1 is the variance of first samaple 
</span><span style="color: #008000;">' dcnt2 is the sample size of sample 2 
</span><span style="color: #008000;">' dvar2 is the variance of second samaple 
</span><span style="color: #008000;">' blnEqVar set TRUE to assume equal variance for the test
</span><span style="color: #008000;">'---------------------------------------------------------------------------------------
</span><span style="color: #008000;">'
</span><span style="color: #000080;">Public</span> <span style="color: #000080;">Function</span> DOFTTESTM(dcnt1 <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, dvar1 <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, dcnt2 <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, dvar2 <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, <span style="color: #000080;">Optional</span> blnEqVar <span style="color: #000080;">As</span> <span style="color: #000080;">Boolean</span> = <span style="color: #000080;">False</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>
&nbsp;
<span style="color: #000080;">Dim</span> dResult <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, dNumer <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>, dDenon <span style="color: #000080;">As</span> <span style="color: #000080;">Double</span>
&nbsp;
<span style="color: #000080;">On</span> <span style="color: #000080;">Error</span> <span style="color: #000080;">GoTo</span> DOFTTESTM_Error
<span style="color: #008000;">'if equal variances are not assumed, then use a complicated formula to compute degrees of freedom
</span><span style="color: #008000;">'http://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm
</span><span style="color: #000080;">If</span> <span style="color: #000080;">Not</span> blnEqVar <span style="color: #000080;">Then</span>
	dNumer = ((dvar1 ^ 2 / dcnt1) + (dvar2 ^ 2 / dcnt2)) ^ 2
	dDenon = ((dvar1 ^ 2 / dcnt1) ^ 2 / (dcnt1 - 1)) + ((dvar2 ^ 2 / dcnt2) ^ 2 / (dcnt2 - 1))
	dResult = dNumer / dDenon
<span style="color: #000080;">Else</span>
	dResult = dcnt1 + dcnt2 - 2
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
DOFTTESTM = dResult
&nbsp;
<span style="color: #000080;">Exit</span> <span style="color: #000080;">Function</span>
&nbsp;
DOFTTESTM_Error:
	DOFTTESTM = Null
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://nandeshwar.info/2008/10/29/students-t-test-for-equal-means/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert Text to Uppercase</title>
		<link>http://nandeshwar.info/2007/09/17/convert-text-to-uppercase/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=convert-text-to-uppercase</link>
		<comments>http://nandeshwar.info/2007/09/17/convert-text-to-uppercase/#comments</comments>
		<pubDate>Mon, 17 Sep 2007 13:21:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[String Operations]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Useful Procedures]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[UDF]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://a7n9.wordpress.com/2007/09/17/convert-text-to-uppercase/</guid>
		<description><![CDATA[If you want to convert the text to uppercase, use the following code; however, I recommend downloading ASAP Utilities, it has many functionalities, including text conversion. It doesn&#8217;t offer source code though. Here&#8217;s my code for uppercase conversion:(If you want to convert your text to lowercase, replace Ucase with Lcase function in the code) &#8216;Will [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to convert the text to uppercase, use the following code; however, I recommend downloading <a href="http://www.asap-utilities.com/">ASAP Utilities</a>, it has many functionalities, including text conversion. It doesn&#8217;t offer source code though. </p>
<p>Here&#8217;s my code for uppercase conversion:<br />(If you want to convert your text to lowercase, replace Ucase with Lcase function in the code)
<div id="code"><font face="Courier"><span style="color:#007F00;">&#8216;Will convert selected range to Upper case, using array</span><br /><span style="color:#00007F;">Sub</span> Conv2UCase()<br /><span style="color:#00007F;">On</span> <span style="color:#00007F;">Error</span> <span style="color:#00007F;">GoTo</span> Conv2UCase_Error</p>
<p><span style="color:#00007F;">Dim</span> vDataArr <span style="color:#00007F;">As</span> <span style="color:#00007F;">Variant</span><br /><span style="color:#00007F;">Dim</span> lUpperBndRow <span style="color:#00007F;">As</span> <span style="color:#00007F;">Long</span>, lUpperBndCol <span style="color:#00007F;">As</span> <span style="color:#00007F;">Long</span><br /><span style="color:#00007F;">Dim</span> lRow <span style="color:#00007F;">As</span> <span style="color:#00007F;">Long</span>, lCol <span style="color:#00007F;">As</span> <span style="color:#00007F;">Long</span></p>
<p><span style="color:#007F00;">&#8216;store selected values in an array</span><br />vDataArr = Selection<br /><span style="color:#007F00;">&#8216;get the upper bound of rows</span><br />lUpperBndRow = <span style="color:#00007F;">UBound</span>(vDataArr, 1)<br /><span style="color:#007F00;">&#8216;get the upper bound of cols</span><br />lUpperBndCol = <span style="color:#00007F;">UBound</span>(vDataArr, 2)</p>
<p><span style="color:#007F00;">&#8216;Start a loop to go through all the elements of the array</span><br /><span style="color:#00007F;">For</span> lRow = 1 <span style="color:#00007F;">To</span> lUpperBndRow<br />&#160;&#160;&#160;&#160;<span style="color:#00007F;">For</span> lCol = 1 <span style="color:#00007F;">To</span> lUpperBndCol<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#007F00;">&#8216;Check if the value is text, if not don&#8217;t convert</span><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#00007F;">If</span> WorksheetFunction.IsText(vDataArr(lRow, lCol)) <span style="color:#00007F;">Then</span><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#007F00;">&#8216;Convert values to upper case</span><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;vDataArr(lRow, lCol) = UCase(vDataArr(lRow, lCol))<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#00007F;">End</span> <span style="color:#00007F;">If</span><br />&#160;&#160;&#160;&#160;<span style="color:#00007F;">Next</span> lCol<br /><span style="color:#00007F;">Next</span> lRow<br /><span style="color:#007F00;">&#8216;Return the converted values to the range</span><br />Selection = vDataArr<br /><span style="color:#00007F;">Exit</span> <span style="color:#00007F;">Sub</span></p>
<p>Conv2UCase_Error:<br />&#160;&#160;&#160;&#160;MsgBox &#8220;Error &#8221; &amp; Err.Number &amp; &#8221; (&#8221; &amp; Err.Description &amp; &#8220;) in Sub:Conv2UCase&#8221;<br /><span style="color:#00007F;">End</span> <span style="color:#00007F;">Sub</span></font></div>
]]></content:encoded>
			<wfw:commentRss>http://nandeshwar.info/2007/09/17/convert-text-to-uppercase/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Excel Books</title>
		<link>http://nandeshwar.info/2007/09/06/excel-books/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=excel-books</link>
		<comments>http://nandeshwar.info/2007/09/06/excel-books/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 12:56:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Access]]></category>
		<category><![CDATA[Bill Jelen]]></category>
		<category><![CDATA[John Walkenbach]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://a7n9.wordpress.com/2007/09/06/excel-books/</guid>
		<description><![CDATA[Books on my shelf: Professional Excel Development by Stephen Bullen, Rob Bovey This is by far the most authoritative book on Excel development from Add-ins to APIs. A word of caution though, it is not for the beginners. Excel Advanced Report Development by Timothy Zapawa Ever wondered on using Excel as a report development tool? [...]]]></description>
			<content:encoded><![CDATA[<p><!--noadsense--></p>
<div class="nobrtable">
<table border="0" width="100%">
<tbody>
<tr>
<td>
<div><span style="font-weight:bold;">Books on my shelf:</span></div>
</td>
<td></td>
</tr>
<tr>
<td width="80%"><span style="font-weight:bold;">Professional Excel Development by Stephen Bullen, Rob Bovey<br />
</span></p>
<p>This is by far the most authoritative book on Excel development from Add-ins to APIs. A word of caution though, it is not for the beginners.</td>
<td width="20%"><iframe src="http://rcm.amazon.com/e/cm?t=myexanvbbl-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0321262506&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td>
</tr>
<tr>
<td width="80%"><span style="font-weight:bold;">Excel Advanced Report Development by Timothy Zapawa<br />
</span></p>
<p>Ever wondered on using Excel as a report development tool? This might be an answer to it; however, my problem with this book is that it focuses too much on pivottables, and because of that it doesn?t do justification to the name of the book. At any rate, this is very good book to exploit pivottable to its limits.</td>
<td width="20%"><iframe src="http://rcm.amazon.com/e/cm?t=myexanvbbl-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0764588117&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td>
</tr>
<tr>
<td width="80%"><span style="font-weight:bold;">Excel 2007 Power Programming with VBA by John Walkenbach<br />
</span><br />
Of course, it cannot happen that you talk about Excel books and don?t mention <a href="http://www.j-walk.com/">Mr. Spreadsheet</a> himself. I am his fan on personal and professional level. On personal level, I love his <a href="http://www.j-walkblog.com/">blog</a>, and on professional level, I like his lucid language in his books. I recommend reading his books and blog both.</td>
<td width="20%"><iframe src="http://rcm.amazon.com/e/cm?t=myexanvbbl-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0470044012&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td>
</tr>
<tr>
<td width="80%"><span style="font-weight:bold;">Excel 2003 Formulas by John Walkenbach<br />
</span></p>
<p>You thought you knew formulas? Just read this book and you?ll realize, which I do almost every day, that there just so much about Excel that we don?t know. John uses simple language, and introduces the readers from basic to advanced formulas. How advance you might ask, well, here is an <a href="http://j-walkblog.com/old/2004/12/18/">example</a>, which uses a formula similar to this:<br />
<a href="http://www.nandeshwar.info/projects/xlblog/uploaded_images/Jwalkcalender-728257.jpg"><img style="cursor:pointer;" src="http://www.nandeshwar.info/projects/xlblog/uploaded_images/Jwalkcalender-728254.jpg" border="0" alt="" /></a></td>
<td width="20%"><iframe src="http://rcm.amazon.com/e/cm?t=myexanvbbl-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0764540734&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td>
</tr>
<tr>
<td width="80%"><span style="font-weight:bold;">Excel 2007 Formulas by John Walkenbach<br />
</span></td>
<td width="20%"><iframe src="http://rcm.amazon.com/e/cm?t=myexanvbbl-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0470044020&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td>
</tr>
<tr>
<td>
<div><span style="font-weight:bold;">Books I have Read:</span></div>
</td>
<td></td>
</tr>
<tr>
<td width="80%"><span style="font-weight:bold;">Data Analysis and Decision Making with Microsoft Excel by S. Christian Albright<br />
</span></p>
<p>I borrowed this book from the library. It is a very good for beginners.</td>
<td width="20%"><iframe src="http://rcm.amazon.com/e/cm?t=myexanvbbl-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0324662440&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td>
</tr>
<tr>
<td width="80%"><span style="font-weight:bold;">Excel 2003 Power Programming with VBA by John Walkenbach<br />
</span></td>
<td width="20%"><iframe src="http://rcm.amazon.com/e/cm?t=myexanvbbl-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0764540726&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td>
</tr>
<tr>
<td width="80%"><span style="font-weight:bold;">Integrating Excel and Access by Michael Schmalz<br />
</span><br />
I borrowed this book from the library too. Excellent reference on developing applications using Access, Excel, and VBA.</td>
<td width="20%"><iframe src="http://rcm.amazon.com/e/cm?t=myexanvbbl-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0596009739&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td>
</tr>
<tr>
<td width="80%"><span style="font-weight:bold;">Mr Excel ON EXCEL by Bill Jelen<br />
</span></p>
<p>This is my first book I read on Excel, which is written by Bill Jelen aka Mr. Excel. Fantastic book. If you have begun knowing Excel just now, obtain a copy of this book right away. This is the right start for beginners. It uses very simple and clear language, and Bill provides great examples to make the learning useful.</td>
<td width="20%"><iframe src="http://rcm.amazon.com/e/cm?t=myexanvbbl-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0972425837&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td>
</tr>
<tr>
<td width="80%"><span style="font-weight:bold;">Guerilla Data Analysis Using Microsoft Excel by Bill Jelen<br />
</span></p>
<p>I had an e-version of this book, but for some reason it&#8217;s not working anymore. I had chewed on this book a lot. It?s a great book for starters, especially, in data crunching.</td>
<td width="20%"><iframe src="http://rcm.amazon.com/e/cm?t=myexanvbbl-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0972425802&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></td>
</tr>
</tbody>
</table>
</div>
]]></content:encoded>
			<wfw:commentRss>http://nandeshwar.info/2007/09/06/excel-books/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A function to reverse a string</title>
		<link>http://nandeshwar.info/2007/08/16/a-function-to-reverse-a-string/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-function-to-reverse-a-string</link>
		<comments>http://nandeshwar.info/2007/08/16/a-function-to-reverse-a-string/#comments</comments>
		<pubDate>Thu, 16 Aug 2007 14:19:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[String Operations]]></category>
		<category><![CDATA[Useful Procedures]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[UDF]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://a7n9.wordpress.com/2007/08/16/a-function-to-reverse-a-string/</guid>
		<description><![CDATA[Very simple, uses the VBA function StrReverse to reverse the input string. &#8216;A function to reverse a string provided as input&#8216;For example, the string &#8220;abcd&#8221; will become &#8220;dcba&#8221;&#8216;Uses the VBA function StrReversePublic Function ReverseString(sInputString As String) As StringOn Error GoTo ReverseString_Error&#160;&#160;&#160;&#160;ReverseString = StrReverse(sInputString)&#160;&#160;&#160;&#160;Exit Function ReverseString_Error:&#160;&#160;&#160;&#160;ReverseString = &#8220;#ERROR#&#8221;End Function]]></description>
			<content:encoded><![CDATA[<p>Very simple, uses the VBA function StrReverse to reverse the input string.
<div id="code"><font face="Courier"><span style="color:#007F00;">&#8216;A function to reverse a string provided as input</span><br /><span style="color:#007F00;">&#8216;For example, the string &#8220;abcd&#8221; will become &#8220;dcba&#8221;</span><br /><span style="color:#007F00;">&#8216;Uses the VBA function StrReverse</span><br /><span style="color:#00007F;">Public</span> <span style="color:#00007F;">Function</span> ReverseString(sInputString <span style="color:#00007F;">As</span> String) <span style="color:#00007F;">As</span> String<br /><span style="color:#00007F;">On</span> <span style="color:#00007F;">Error</span> <span style="color:#00007F;">GoTo</span> ReverseString_Error<br />&#160;&#160;&#160;&#160;<br />ReverseString = StrReverse(sInputString)<br />&#160;&#160;&#160;&#160;<span style="color:#00007F;">Exit</span> <span style="color:#00007F;">Function</span></p>
<p>ReverseString_Error:<br />&#160;&#160;&#160;&#160;ReverseString = &#8220;#ERROR#&#8221;<br /><span style="color:#00007F;">End</span> <span style="color:#00007F;">Function</span></font></div>
]]></content:encoded>
			<wfw:commentRss>http://nandeshwar.info/2007/08/16/a-function-to-reverse-a-string/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Concatenate function</title>
		<link>http://nandeshwar.info/2007/07/24/concatenate-function/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=concatenate-function</link>
		<comments>http://nandeshwar.info/2007/07/24/concatenate-function/#comments</comments>
		<pubDate>Tue, 24 Jul 2007 16:24:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[String Operations]]></category>
		<category><![CDATA[Useful Procedures]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[UDF]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://a7n9.wordpress.com/2007/07/24/concatenate-function/</guid>
		<description><![CDATA[Oh, man, I can&#8217;t tell how useful that concatenate function is. One repetitive use I found is to create OR/AND conditions for Access queries. I copy-paste the field values of a column from Access, do some filtering and my conditions are ready. Then I use this concatfunc to create a string to use in my [...]]]></description>
			<content:encoded><![CDATA[<p>Oh, man, I can&#8217;t tell how useful that <a href="http://www.nandeshwar.info/projects/xlblog/2007/06/range-concatenation-with-character.html">concatenate function</a> is.</p>
<p>One repetitive use I found is to create OR/AND conditions for Access queries. I copy-paste the field values of a column from Access, do some filtering and my conditions are ready. Then I use this concatfunc to create a string to use in my Access query.</p>
<p>For example, look at this print screen:<br /><a href="http://www.nandeshwar.info/projects/xlblog/uploaded_images/concatfuncex-714057.JPG"><img style="cursor:hand;" src="http://www.nandeshwar.info/projects/xlblog/uploaded_images/concatfuncex-714053.JPG" border="0" alt="" /></a></p>
<p>The Range A1:A4 houses the string condition I want to use in my Access query to restrict the fruits from my data. In cell B1 I have the formula
<div id="code">=PERSONAL.XLS!concatfunc(A1:A4,CHAR(34) &amp; &#8221; or &#8221; &amp; CHAR(34))</div>
<p>, and the return string from this function is listed in cell B1.</p>
<p>Now, all you have to do is copy and paste this in Access criteria and put a quotation mark at the start and at the end of this string.</p>
<p>I have found one more use of this when I want to store some values in an Array, using the <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbenlr98/html/vafctarray.asp">Array function in VBA</a>.</p>
<p>One more print screen:<br /><a href="http://www.nandeshwar.info/projects/xlblog/uploaded_images/concatfuncex2-714067.JPG"><img style="cursor:hand;" src="http://www.nandeshwar.info/projects/xlblog/uploaded_images/concatfuncex2-714065.JPG" border="0" alt="" /></a></p>
<p>In this example, I insert a comma (CHAR(44) instead of string OR, and this function returns a string that I can use in VBA to store these values in an array using Array function, after adding a quotation mark, of course, at the start and at the end.</p>
]]></content:encoded>
			<wfw:commentRss>http://nandeshwar.info/2007/07/24/concatenate-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Access VBA: Convert Access tables to arff format</title>
		<link>http://nandeshwar.info/2007/07/18/access-vba-convert-access-tables-to-arff-format/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=access-vba-convert-access-tables-to-arff-format</link>
		<comments>http://nandeshwar.info/2007/07/18/access-vba-convert-access-tables-to-arff-format/#comments</comments>
		<pubDate>Wed, 18 Jul 2007 20:37:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Access]]></category>
		<category><![CDATA[Useful Procedures]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://a7n9.wordpress.com/2007/07/18/access-vba-convert-access-tables-to-arff-format/</guid>
		<description><![CDATA[Weka, an open source data mining software, uses arff input data format. You can use this code to convert any Access table to arff format. Download the Access database with code: Convert2Arff.mdb This can very well be designed using forms, but this should get one started. Use Alt + F11 to see the code, then [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cs.waikato.ac.nz/ml/weka/">Weka</a>, an open source data mining software, uses <a href="http://www.cs.waikato.ac.nz/~ml/weka/arff.html">arff input data format</a>. You can use this code to convert any Access table to arff format. Download the Access database with code: <a href="http://nandeshwar.info/wp-content/uploads/Convert2Arff.mdb">Convert2Arff.mdb</a></p>
<p>This can very well be designed using forms, but this should get one started. Use Alt + F11 to see the code, then execute procedure ConvertTbl2Arff to convert a table.</p>
<p>Some highlights of this procedure<br />
- Takes care of spaces in Attribute name and data values<br />
- Finds unique values of nominal variables<br />
- Assigns equivalent ARFF datatype<br />
- Replaces missing values with question marks</p>
]]></content:encoded>
			<wfw:commentRss>http://nandeshwar.info/2007/07/18/access-vba-convert-access-tables-to-arff-format/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Access VBA: Export Access tables using ODBC</title>
		<link>http://nandeshwar.info/2007/07/18/access-vba-export-access-tables-using-odbc/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=access-vba-export-access-tables-using-odbc</link>
		<comments>http://nandeshwar.info/2007/07/18/access-vba-export-access-tables-using-odbc/#comments</comments>
		<pubDate>Wed, 18 Jul 2007 20:28:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Access]]></category>
		<category><![CDATA[Useful Procedures]]></category>
		<category><![CDATA[ODBC]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://a7n9.wordpress.com/2007/07/18/access-vba-export-access-tables-using-odbc/</guid>
		<description><![CDATA[If you want to export Access tables using ODBC/DSN connections, use the following code. This procedure uses the File DSN and ODBC connection to export Access tables using DAO object TableDef. Sub ExportTbls() Dim sTblNm As String Dim sTypExprt As String Dim sCnxnStr As String, vStTime As Variant Dim db As Database, tbldef As DAO.TableDef [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to export Access tables using ODBC/DSN connections, use the following code. This procedure uses the File DSN and ODBC connection to export Access tables using DAO object TableDef.</p>
<div id="code"><span style="font-family: Courier;"><span style="color:#00007F;">Sub</span> ExportTbls()</span></p>
<p><span style="color:#00007F;"><span style="font-family: Courier;">Dim</span></span><span style="font-family: Courier;"> sTblNm <span style="color:#00007F;">As</span> <span style="color:#00007F;">String</span><br />
<span style="color:#00007F;">Dim</span> sTypExprt <span style="color:#00007F;">As</span> <span style="color:#00007F;">String</span><br />
<span style="color:#00007F;">Dim</span> sCnxnStr  <span style="color:#00007F;">As</span> <span style="color:#00007F;">String</span>, vStTime <span style="color:#00007F;">As</span> <span style="color:#00007F;">Variant</span><br />
<span style="color:#00007F;">Dim</span> db <span style="color:#00007F;">As</span> Database, tbldef <span style="color:#00007F;">As</span> DAO.TableDef</span></p>
<p><span style="color:#00007F;"><span style="font-family: Courier;">On</span></span><span style="font-family: Courier;"> <span style="color:#00007F;">Error</span> <span style="color:#00007F;">GoTo</span> ExportTbls_Error</span></p>
<p><span style="font-family: Courier;">sTypExprt = &#8220;ODBC Database&#8221; <span style="color:#007F00;">&#8216;Export Type</span><br />
sCnxnStr = &#8220;ODBC;DSN=DSNName;UID=userID;PWD=password&#8221; <span style="color:#007F00;">&#8216;Create the connection string</span></span></p>
<p><span style="font-family: Courier;">vStTime = Timer<br />
Application.Echo <span style="color:#00007F;">False</span>, &#8220;Visual Basic code is executing.&#8221;</span></p>
<p><span style="color:#00007F;"><span style="font-family: Courier;">Set</span></span><span style="font-family: Courier;"> db = CurrentDb()</span></p>
<p><span style="color:#007F00;"><span style="font-family: Courier;">&#8216;need a reference to Microsoft DAO 3.x library</span></span><span style="font-family: Courier;"><br />
<span style="color:#00007F;">For</span> <span style="color:#00007F;">Each</span> tbldef <span style="color:#00007F;">In</span> db.TableDefs<br />
<span style="color:#007F00;">&#8216;Don&#8217;t export System and temporary tables</span><br />
<span style="color:#00007F;">If</span> Left(tbldef.Name, 4)  &#8220;MSys&#8221; And Left(tbldef.Name, 4)  &#8220;~TMP&#8221; <span style="color:#00007F;">Then</span><br />
<span style="color:#007F00;">&#8216;Debug.Print tbldef.Name</span><br />
sTblNm = tbldef.Name<br />
DoCmd.TransferDatabase acExport, sTypExprt, sCnxnStr, acTable, sTblNm, sTblNm<br />
<span style="color:#00007F;">End</span> <span style="color:#00007F;">If</span><br />
<span style="color:#00007F;">Next</span> tbldef</span></p>
<p><span style="font-family: Courier;">MsgBox &#8220;Done! Time taken=&#8221; &amp; Timer &#8211; vStTime</span></p>
<p><span style="color:#00007F;"><span style="font-family: Courier;">On</span></span><span style="font-family: Courier;"> <span style="color:#00007F;">Error</span> <span style="color:#00007F;">GoTo</span> 0<br />
SmoothExit_ExportTbls:<br />
<span style="color:#00007F;">Set</span> db = <span style="color:#00007F;">Nothing</span><br />
Application.Echo <span style="color:#00007F;">True</span><br />
<span style="color:#00007F;">Exit</span> <span style="color:#00007F;">Sub</span></span></p>
<p><span style="font-family: Courier;">ExportTbls_Error:<br />
MsgBox &#8220;Error &#8221; &amp; Err.Number &amp; &#8221; (&#8221; &amp; Err.Description &amp; &#8220;) in procedure ExportTblsODST&#8221;<br />
<span style="color:#00007F;">Resume</span> SmoothExit_ExportTbls<br />
<span style="color:#00007F;">End</span> <span style="color:#00007F;">Sub</span></span></div>
]]></content:encoded>
			<wfw:commentRss>http://nandeshwar.info/2007/07/18/access-vba-export-access-tables-using-odbc/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Access VBA: Delete tables from Access database</title>
		<link>http://nandeshwar.info/2007/07/18/access-vba-delete-tables-from-access-database/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=access-vba-delete-tables-from-access-database</link>
		<comments>http://nandeshwar.info/2007/07/18/access-vba-delete-tables-from-access-database/#comments</comments>
		<pubDate>Wed, 18 Jul 2007 20:21:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Access]]></category>
		<category><![CDATA[Useful Procedures]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://a7n9.wordpress.com/2007/07/18/access-vba-delete-tables-from-access-database/</guid>
		<description><![CDATA[If you want to delete all or some of the tables from your Access database, you can use this DAO approach. You would need a reference to Microsoft DAO 3.x object library. As shown in the example, you can use an array to store the table names, which you want to keep or delete. Sub [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to delete all or some of the tables from your Access database, you can use this DAO approach. You would need a reference to Microsoft DAO 3.x object library. As shown in the example, you can use an array to store the table names, which you want to keep or delete.</p>
<div id="code"><font face="Courier"><span style="color:#00007F;">Sub</span> DelteTbls()<br /><span style="color:#00007F;">Dim</span> sTblNm <span style="color:#00007F;">As</span> <span style="color:#00007F;">String</span><br /><span style="color:#00007F;">Dim</span> db <span style="color:#00007F;">As</span> Database, tbldef <span style="color:#00007F;">As</span> DAO.TableDef<br /><span style="color:#00007F;">Dim</span> i <span style="color:#00007F;">As</span> <span style="color:#00007F;">Integer</span>, Arr <span style="color:#00007F;">As</span> <span style="color:#00007F;">Variant</span></p>
<p><span style="color:#00007F;">On</span> <span style="color:#00007F;">Error</span> <span style="color:#00007F;">GoTo</span> DelteTbls_Error<br /><span style="color:#007F00;">&#8216;You can use an array if you want to delete or not delete specific tables</span><br /><span style="color:#007F00;">&#8216;Arr = Array(&#8220;Table1&#8243;,&#8221;Table2&#8243;,&#8221;Table3&#8243;)</span></p>
<p><span style="color:#00007F;">Set</span> db = CurrentDb() <span style="color:#007F00;">&#8216;Set the database object</span></p>
<p><span style="color:#007F00;">&#8216;Set the warnings off to suppress messages</span><br />DoCmd.SetWarnings <span style="color:#00007F;">False</span></p>
<p><span style="color:#007F00;">&#8216;For i = 0 To UBound(Arr)</span><br />&#160;&#160;&#160;&#160;<span style="color:#00007F;">For</span> <span style="color:#00007F;">Each</span> tbldef <span style="color:#00007F;">In</span> db.TableDefs<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#007F00;">&#8216;here you can use equal to or not equal to delete or keep specific tables</span><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#007F00;">&#8216;If Left(tbldef.Name, 4) = Arr(i) Then</span><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#007F00;">&#8216;Don&#8217;t delete System or temporary tables</span><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#00007F;">If</span> Left(tbldef.Name, 4)  &#8220;MSys&#8221; And Left(tbldef.Name, 1)  &#8220;~&#8221; <span style="color:#00007F;">Then</span><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Debug.Print tbldef.Name<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;sTblNm = tbldef.Name<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#007F00;">&#8216;Delete table</span><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;DoCmd.DeleteObject acTable, sTblNm<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#00007F;">End</span> <span style="color:#00007F;">If</span><br />&#160;&#160;&#160;&#160;<span style="color:#00007F;">Next</span> tbldef<br /><span style="color:#007F00;">&#8216;Next i</span></p>
<p>MsgBox &#8220;Done!&#8221;</p>
<p><span style="color:#00007F;">On</span> <span style="color:#00007F;">Error</span> <span style="color:#00007F;">GoTo</span> 0</p>
<p>SmoothExit_DelteTbls:<br />&#160;&#160;&#160;&#160;<span style="color:#00007F;">Set</span> db = <span style="color:#00007F;">Nothing</span><br />&#160;&#160;&#160;&#160;DoCmd.SetWarnings <span style="color:#00007F;">True</span><br />&#160;&#160;&#160;&#160;<span style="color:#00007F;">Exit</span> <span style="color:#00007F;">Sub</span></p>
<p>DelteTbls_Error:<br />&#160;&#160;&#160;&#160;MsgBox &#8220;Error &#8221; &amp; Err.Number &amp; &#8221; (&#8221; &amp; Err.Description &amp; &#8220;) in procedure DelteTbls&#8221;<br />&#160;&#160;&#160;&#160;<span style="color:#00007F;">Resume</span> SmoothExit_DelteTbls<br /><span style="color:#00007F;">End</span> <span style="color:#00007F;">Sub</span><br /></font></div>
]]></content:encoded>
			<wfw:commentRss>http://nandeshwar.info/2007/07/18/access-vba-delete-tables-from-access-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

