<?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>Diário de um DBA &#187; Macro</title>
	<atom:link href="http://silasmendes.com/dba/tag/macro/feed" rel="self" type="application/rss+xml" />
	<link>http://silasmendes.com/dba</link>
	<description>Tecnologia &#38; Banco de Dados</description>
	<lastBuildDate>Sun, 15 Apr 2012 12:20:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Macro no Excel, coisas da rotina</title>
		<link>http://silasmendes.com/dba/macro-no-excel-coisas-da-rotina</link>
		<comments>http://silasmendes.com/dba/macro-no-excel-coisas-da-rotina#comments</comments>
		<pubDate>Wed, 02 Jul 2008 19:47:22 +0000</pubDate>
		<dc:creator>Silas Mendes</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[SQL SERVER 2000]]></category>
		<category><![CDATA[SQL SERVER 2005]]></category>
		<category><![CDATA[SQL SERVER 2008]]></category>
		<category><![CDATA[SQL SERVER 2008 R2]]></category>
		<category><![CDATA[SQL SERVER 7]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Macro]]></category>
		<category><![CDATA[Planilha]]></category>
		<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[VB]]></category>

		<guid isPermaLink="false">http://diariodba.wordpress.com/?p=12</guid>
		<description><![CDATA[  É inevitável na rotina de um DBA ter que utilizar-se de ferramentas que auxiliem seu trabalho. Ontem recebi uma planilha no seguinte formato: SETOR SubSetor Regra Subregra Código Descrição 1 01.1       Bla bla bla     &#8230; <a href="http://silasmendes.com/dba/macro-no-excel-coisas-da-rotina">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>É inevitável na rotina de um DBA ter que utilizar-se de ferramentas que auxiliem seu trabalho.</p>
<p>Ontem recebi uma planilha no seguinte formato:</p>
<table style="width:290pt;border-collapse:collapse;" border="0" cellspacing="0" cellpadding="0" width="387">
<col style="width:48pt;" span="5" width="64"></col>
<col style="width:50pt;" span="1" width="67"></col>
<tbody>
<tr style="height:25.5pt;">
<td class="xl22" style="border-right:#ece9d8;border-top:windowtext 1pt solid;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:yellow;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;"><strong>SETOR</strong></span></td>
<td class="xl23" style="border-right:#ece9d8;border-top:windowtext 1pt solid;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:yellow;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong>SubSetor</strong></span></td>
<td class="xl23" style="border-right:#ece9d8;border-top:windowtext 1pt solid;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:yellow;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong>Regra</strong></span></td>
<td class="xl23" style="border-right:#ece9d8;border-top:windowtext 1pt solid;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:yellow;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong>Subregra</strong></span></td>
<td class="xl23" style="border-right:#ece9d8;border-top:windowtext 1pt solid;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:yellow;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong>Código</strong></span></td>
<td class="xl24" style="border-right:windowtext 1pt solid;border-top:windowtext 1pt solid;border-left:#ece9d8;width:50pt;border-bottom:#ece9d8 0.5pt;background-color:yellow;" width="67"><span style="font-size:x-small;font-family:Arial;"><strong>Descrição</strong></span></td>
</tr>
<tr style="height:25.5pt;">
<td class="xl25" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:transparent;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;"><strong>1</strong></span></td>
<td class="xl26" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong>01.1</strong></span></td>
<td class="xl26" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong> </strong></span></td>
<td class="xl26" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong> </strong></span></td>
<td class="xl26" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong> </strong></span></td>
<td class="xl27" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:50pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="67"><span style="font-size:x-small;font-family:Arial;"><strong>Bla bla bla</strong></span></td>
</tr>
<tr style="height:25.5pt;">
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:transparent;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;"><em><strong> </strong></em></span></td>
<td class="xl29" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"><em><strong> </strong></em></span></td>
<td class="xl29" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"><em><strong>01.11</strong></em></span></td>
<td class="xl29" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"><em><strong> </strong></em></span></td>
<td class="xl29" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"><em><strong> </strong></em></span></td>
<td class="xl30" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:50pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="67"><em><span style="font-size:x-small;font-family:Arial;"><strong>Bla bla la</strong></span></em></td>
</tr>
<tr style="height:25.5pt;">
<td class="xl25" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:transparent;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;"><strong> </strong></span></td>
<td class="xl26" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong> </strong></span></td>
<td class="xl26" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong> </strong></span></td>
<td class="xl26" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong>01.11-3</strong></span></td>
<td class="xl26" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong> </strong></span></td>
<td class="xl27" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:50pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="67"><strong><span style="font-size:x-small;font-family:Arial;">Bla bla bla</span></strong></td>
</tr>
<tr style="height:25.5pt;">
<td class="xl31" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:transparent;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl32" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl32" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl32" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl32" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">0111-3/01</span></td>
<td class="xl33" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:50pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="67"><span style="font-size:x-small;font-family:Arial;">Bla bla bla</span></td>
</tr>
<tr style="height:25.5pt;">
<td class="xl31" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:transparent;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl32" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl32" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl32" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl32" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">0111-3/02</span></td>
<td class="xl33" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:50pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="67"><span style="font-size:x-small;font-family:Arial;">Bla bla bla</span></td>
</tr>
<tr style="height:25.5pt;">
<td class="xl31" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:transparent;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl32" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl32" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl32" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl32" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">0111-3/03</span></td>
<td class="xl33" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:50pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="67"><span style="font-size:x-small;font-family:Arial;">Bla bla bla</span></td>
</tr>
<tr style="height:26.25pt;">
<td class="xl34" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:windowtext 1pt solid;height:26.25pt;background-color:transparent;" width="64" height="35"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl35" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:windowtext 1pt solid;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl35" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:windowtext 1pt solid;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl35" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:windowtext 1pt solid;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;"> </span></td>
<td class="xl35" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:windowtext 1pt solid;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">0111-3/99</span></td>
<td class="xl36" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:50pt;border-bottom:windowtext 1pt solid;background-color:transparent;" width="67"><span style="font-size:x-small;font-family:Arial;">Bla bla bla</span></td>
</tr>
</tbody>
</table>
<p>Eu deveria importar esta planilha numa tabela de nosso banco. Dentro da tabela ela ficaria mais ou menos assim:</p>
<table style="width:288pt;border-collapse:collapse;" border="0" cellspacing="0" cellpadding="0" width="384">
<col style="width:48pt;" span="6" width="64"></col>
<tbody>
<tr style="height:25.5pt;">
<td class="xl24" style="border-right:#ece9d8;border-top:windowtext 1pt solid;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:yellow;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;"><strong>SETOR</strong></span></td>
<td class="xl25" style="border-right:#ece9d8;border-top:windowtext 1pt solid;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:yellow;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong>SubSetor</strong></span></td>
<td class="xl25" style="border-right:#ece9d8;border-top:windowtext 1pt solid;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:yellow;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong>Regra</strong></span></td>
<td class="xl25" style="border-right:#ece9d8;border-top:windowtext 1pt solid;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:yellow;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong>Subregra</strong></span></td>
<td class="xl25" style="border-right:#ece9d8;border-top:windowtext 1pt solid;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:yellow;" width="64"><span style="font-size:x-small;font-family:Arial;"><strong>Código</strong></span></td>
<td class="xl26" style="border-right:windowtext 1pt solid;border-top:windowtext 1pt solid;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:yellow;" width="64"><strong><span style="font-size:x-small;font-family:Arial;">Descrição</span></strong></td>
</tr>
<tr style="height:25.5pt;">
<td class="xl27" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:transparent;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;">1</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.1</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">NULL</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">NULL</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">NULL</span></td>
<td class="xl29" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">Bla bla bla</span></td>
</tr>
<tr style="height:25.5pt;">
<td class="xl27" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:transparent;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;">1</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.1</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.11</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">NULL</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">NULL</span></td>
<td class="xl29" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">Bla bla bla</span></td>
</tr>
<tr style="height:25.5pt;">
<td class="xl27" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:transparent;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;">1</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.1</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.11</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.11-3</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">NULL</span></td>
<td class="xl29" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">Bla bla bla</span></td>
</tr>
<tr style="height:25.5pt;">
<td class="xl27" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:transparent;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;">1</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.1</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.11</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.11-3</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">0111-3/01</span></td>
<td class="xl29" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">Bla bla bla</span></td>
</tr>
<tr style="height:25.5pt;">
<td class="xl27" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:transparent;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;">1</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.1</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.11</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.11-3</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">0111-3/02</span></td>
<td class="xl29" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">Bla bla bla</span></td>
</tr>
<tr style="height:25.5pt;">
<td class="xl27" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:#ece9d8 0.5pt;height:25.5pt;background-color:transparent;" width="64" height="34"><span style="font-size:x-small;font-family:Arial;">1</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.1</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.11</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.11-3</span></td>
<td class="xl28" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">0111-3/03</span></td>
<td class="xl29" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:#ece9d8 0.5pt;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">Bla bla bla</span></td>
</tr>
<tr style="height:26.25pt;">
<td class="xl30" style="border-right:#ece9d8;border-top:#ece9d8;border-left:windowtext 1pt solid;width:48pt;border-bottom:windowtext 1pt solid;height:26.25pt;background-color:transparent;" width="64" height="35"><span style="font-size:x-small;font-family:Arial;">1</span></td>
<td class="xl31" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:windowtext 1pt solid;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.1</span></td>
<td class="xl31" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:windowtext 1pt solid;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.11</span></td>
<td class="xl31" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:windowtext 1pt solid;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">01.11-3</span></td>
<td class="xl31" style="border-right:#ece9d8;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:windowtext 1pt solid;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">0111-3/99</span></td>
<td class="xl32" style="border-right:windowtext 1pt solid;border-top:#ece9d8;border-left:#ece9d8;width:48pt;border-bottom:windowtext 1pt solid;background-color:transparent;" width="64"><span style="font-size:x-small;font-family:Arial;">Bla bla bla</span></td>
</tr>
</tbody>
</table>
<p>Ok&#8230; existe uma hierarquia que visualmente fica melhor representada na primeira tabela, no entanto, dentro do banco os dados deveriam estar como exposto na segunda tabela, isso iria influenciar na chave primária e etc.</p>
<p>Enfim, vamos lá!</p>
<p>Mas faltou um detalhe&#8230; a tabela tinha algumas milhares de linhas. Como eu faria isso? CTRL C, CTRL V?? Quantas horas de um trabalho monótono copiando e colando, copiando e colando&#8230;</p>
<p>Bha!</p>
<p>Nessas horas eu adoro o Excel e suas macros. Para muitos pode parecer ridiculo mas me ajuda e talvez possa ajudar outras pessoas em situação parecida.</p>
<p>Ok&#8230; fiz um pequeno script que varria todas as linhas de uma determinada coluna da planilha, verificando se existiam células vazias. Se a célula está vazia, esta deve receber o conteúdo da célula anterior e assim por diante até o fim.</p>
<p>Muito simples e o trabalho todo, incluindo a importação no banco, não durou 1 hora. Então segue aí o script em VB, escrito dentro do próprio Excel:</p>
<p>Sub Copia_Celula_Anterior()<br />
&#8216;<br />
&#8216; Copia_Celula_Anterior() Macro<br />
&#8216; Macro gravada em 1/7/2008 por silas.mendes<br />
&#8216;</p>
<p><span style="color:#339966;">&#8216;Declara váriavel de apoio do contador</span><br />
Dim i As Integer</p>
<p><span style="color:#008000;">&#8216;Inicializa váriavel com a primeira linha preenchida da planilha<br />
&#8216;ATENÇÃO: Esta informação sera copiada para outra(s) célula(s), caso<br />
&#8216;esteja(m) vazia(s).</span><br />
i = 8</p>
<p><span style="color:#008000;">&#8216;Varre todas a linhas da coluna até a linha 2371</span><br />
Do While i &lt; 2371<br />
<span style="color:#008000;">&#8216;Verifica se a célula atual está vazia</span><br />
If Range(&#8220;E&#8221; &amp; i).Value = &#8220;&#8221; Then<br />
<span style="color:#008000;">&#8216;Se a célula está vazia, seleciona a última célula</span><br />
Range(&#8220;E&#8221; &amp; i &#8211; 1).Select<br />
<span style="color:#008000;">&#8216;Copia os dados da célula selecionada</span><br />
Selection.Copy<br />
<span style="color:#008000;">&#8216;Volta a selecionar a célula vazia (atual no loop)</span><br />
Range(&#8220;E&#8221; &amp; i).Select<br />
<span style="color:#008000;">&#8216;Cola o conteúdo na célula vazia</span><br />
ActiveSheet.Paste<br />
End If<br />
<span style="color:#008000;">&#8216;Incrementa contador do Loop</span><br />
i = i + 1</p>
<p>Loop</p>
<p>End Sub</p>
<p> </p>
<p>É, isso também faz parte da rotina de um DBA :))</p>
]]></content:encoded>
			<wfw:commentRss>http://silasmendes.com/dba/macro-no-excel-coisas-da-rotina/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

