<?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>simple blog いろいろ勉強中</title>
	<atom:link href="http://www.simple-sys.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simple-sys.com/blog</link>
	<description>いろんなサイトから勉強のネタを拾ってきて独学中です</description>
	<lastBuildDate>Fri, 08 Jan 2010 15:01:11 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>表を縦に展開</title>
		<link>http://www.simple-sys.com/blog/2010/01/09/363/</link>
		<comments>http://www.simple-sys.com/blog/2010/01/09/363/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 15:01:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[VBAのお勉強]]></category>

		<guid isPermaLink="false">http://www.simple-sys.com/blog/?p=363</guid>
		<description><![CDATA[

http://q.hatena.ne.jp/1262665566
関数でもできるけど、ＶＢＡでやってみました。
vbastudy_28.xls
こちらをダウンロードして、開きます。
ツール→マクロ→Visual Ba [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p><a href="http://q.hatena.ne.jp/1262665566" target="_blank">http://q.hatena.ne.jp/1262665566</a></p>
<p>関数でもできるけど、ＶＢＡでやってみました。</p>
<p><a href="http://www.simple-sys.com/blog/wp-content/uploads/2010/01/vbastudy_28.xls">vbastudy_28.xls</a><br />
こちらをダウンロードして、開きます。</p>
<p>ツール→マクロ→Visual Basic Editorと開き、</p>
<p><a href="http://www.simple-sys.com/blog/wp-content/uploads/2010/01/saisei.gif"><img class="alignnone size-full wp-image-365" title="saisei" src="http://www.simple-sys.com/blog/wp-content/uploads/2010/01/saisei.gif" alt="saisei" width="20" height="18" /></a>みたいなボタンをクリック。</p>
<p>罫線、右寄せも同時にやってます（＾＾）</p>
<p>プログラムはこんな感じ。</p>
<div class="igBar"><span id="lvb-2"><a href="#" onclick="javascript:showCodeTxt('vb-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Visual Basic:</span>
<div id="vb-2">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Sub</span> test<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> hyouAlastgyou <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> hyouAgyou <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Dim</span> hyouBgyou <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080;">'A列の最終行を求めます。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">hyouAlastgyou = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>ActiveSheet.<span style="color: #66cc66;">Rows</span>.<span style="color: #b1b100;">Count</span>, <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #b1b100;">End</span><span style="color:#006600; font-weight:bold;">&#40;</span>xlUp<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Row</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080;">'表Bを1行目から値を入れていくとします。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">hyouBgyou = <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080;">'A列が２行目からlastgyouまで入っているとして、</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080;">'それを１行ずつとっていきます。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">For</span> hyouAgyou = <span style="color: #cc66cc;color:#800000;">2</span> <span style="color: #b1b100;">To</span> hyouAlastgyou</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #808080;">' hyouBgyou行目の8番目の列(H)に「品番」を代入します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouBgyou, <span style="color: #cc66cc;color:#800000;">8</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = <span style="color: #ff0000;">"品番"</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #808080;">' hyouAgyou 行目 の　1番目の列(A列)の値を、hyouBgyou行目の9番目の列(I列)に代入します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouBgyou, <span style="color: #cc66cc;color:#800000;">9</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouAgyou, <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'表Bを次の行に移します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; hyouBgyou = hyouBgyou + <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #808080;">' hyouBgyou行目の8番目の列(H)に「動物種類」を代入します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouBgyou, <span style="color: #cc66cc;color:#800000;">8</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = <span style="color: #ff0000;">"動物種類"</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #808080;">' hyouAgyou 行目 の　2番目の列(B列)の値を、hyouBgyou行目の9番目の列(I列)に代入します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouBgyou, <span style="color: #cc66cc;color:#800000;">9</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouAgyou, <span style="color: #cc66cc;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #808080;">' hyouBgyou行目の9番目の列(I列)を右寄せにします。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouBgyou, <span style="color: #cc66cc;color:#800000;">9</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">HorizontalAlignment</span> = xlRight</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'表Bを次の行に移します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; hyouBgyou = hyouBgyou + <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #808080;">' hyouBgyou行目の8番目の列(H)に「色」を代入します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouBgyou, <span style="color: #cc66cc;color:#800000;">8</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = <span style="color: #ff0000;">"色"</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #808080;">' hyouAgyou 行目 の　3番目の列(C列)の値を、hyouBgyou行目の9番目の列(I列)に代入します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouBgyou, <span style="color: #cc66cc;color:#800000;">9</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouAgyou, <span style="color: #cc66cc;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #808080;">' hyouBgyou行目の9番目の列(I列)を右寄せにします。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouBgyou, <span style="color: #cc66cc;color:#800000;">9</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">HorizontalAlignment</span> = xlRight</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'表Bを次の行に移します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; hyouBgyou = hyouBgyou + <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #808080;">' hyouBgyou行目の8番目の列(H)に「価格」を代入します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouBgyou, <span style="color: #cc66cc;color:#800000;">8</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = <span style="color: #ff0000;">"価格"</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #808080;">' hyouAgyou 行目 の　5番目の列(E列)の値を、hyouBgyou行目の9番目の列(I列)に代入します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouBgyou, <span style="color: #cc66cc;color:#800000;">9</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>hyouAgyou, <span style="color: #cc66cc;color:#800000;">5</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'今現在の行から3行前の8番目の列(H列)から、今の行の9番目の列(I列)の部分に罫線を引きます。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Range</span><span style="color:#006600; font-weight:bold;">&#40;</span>Cells<span style="color:#006600; font-weight:bold;">&#40;</span>hyouBgyou - <span style="color: #cc66cc;color:#800000;">3</span>, <span style="color: #cc66cc;color:#800000;">8</span><span style="color:#006600; font-weight:bold;">&#41;</span>, Cells<span style="color:#006600; font-weight:bold;">&#40;</span>hyouBgyou, <span style="color: #cc66cc;color:#800000;">9</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Borders</span>.<span style="color: #66cc66;">LineStyle</span> = <span style="color: #b1b100;">True</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'表Bを次の次の行に移します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; hyouBgyou = hyouBgyou + <span style="color: #cc66cc;color:#800000;">2</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080;">'表Aを次の行に移します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Next</span> hyouAgyou</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simple-sys.com/blog/2010/01/09/363/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>文字列が入っていたら抜き出す処理をワークシート関数で</title>
		<link>http://www.simple-sys.com/blog/2009/03/13/351/</link>
		<comments>http://www.simple-sys.com/blog/2009/03/13/351/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 00:19:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[VBAのお勉強]]></category>

		<guid isPermaLink="false">http://www.simple-sys.com/blog/?p=351</guid>
		<description><![CDATA[

http://q.hatena.ne.jp/1236879956

こんな感じにしたいのかな？(^^;

まず、A列が通勤手段だとします。
A列に「自動車」という文字列や「自動二輪」という文字列が含まれていた場合、「 [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p><a href="http://q.hatena.ne.jp/1236879956" target="_blank">http://q.hatena.ne.jp/1236879956</a></p>
<p><img class="alignnone size-full wp-image-352" title="400" src="http://www.simple-sys.com/blog/wp-content/uploads/2009/03/400.jpg" alt="400" width="370" height="258" /></p>
<p>こんな感じにしたいのかな？(^^;<br />
<span id="more-351"></span><br />
まず、A列が通勤手段だとします。</p>
<p>A列に「自動車」という文字列や「自動二輪」という文字列が含まれていた場合、「値を切り取って」とあるんですけど、この「切り取る」ってどう切り取るのか、よくわからないですね。。。<br />
 <br />
「含まれていた場合、=から後ろの文字列を切り取る」<br />
ということでいいのかな？</p>
<p>だとすると、B列の自動車の列の計算式は、B2だったら、</p>
<div class="igBar"><span id="lvb-5"><a href="#" onclick="javascript:showCodeTxt('vb-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Visual Basic:</span>
<div id="vb-5">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">=<span style="color: #b1b100;">IF</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #b1b100;">ISERROR</span><span style="color:#006600; font-weight:bold;">&#40;</span>SEARCH<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"自動車"</span>,A2<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>,<span style="color: #ff0000;">""</span>,<span style="color: #b1b100;">MID</span><span style="color:#006600; font-weight:bold;">&#40;</span>A2,SEARCH<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"="</span>,A2<span style="color:#006600; font-weight:bold;">&#41;</span>+<span style="color: #cc66cc;color:#800000;">1</span>,<span style="color: #b1b100;">LEN</span><span style="color:#006600; font-weight:bold;">&#40;</span>A2<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
 <br />
C列の自動二輪の列の計算式は、C2だったら、</p>
<div class="igBar"><span id="lvb-6"><a href="#" onclick="javascript:showCodeTxt('vb-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Visual Basic:</span>
<div id="vb-6">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">=<span style="color: #b1b100;">IF</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #b1b100;">ISERROR</span><span style="color:#006600; font-weight:bold;">&#40;</span>SEARCH<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"自動二輪"</span>,A2<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>,<span style="color: #ff0000;">""</span>,<span style="color: #b1b100;">MID</span><span style="color:#006600; font-weight:bold;">&#40;</span>A2,SEARCH<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"="</span>,A2<span style="color:#006600; font-weight:bold;">&#41;</span>+<span style="color: #cc66cc;color:#800000;">1</span>,<span style="color: #b1b100;">LEN</span><span style="color:#006600; font-weight:bold;">&#40;</span>A2<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
 <br />
でいいのかな？</p>
<p>まず、SEARCH関数でそれぞれの文字がA列に入っているかどうかを調べ、<br />
入っていない場合は#VALUE!というエラーになるので、ISERROR関数を使用して<br />
それを調べ、エラーだったら　""　、つまり、何も表示させない。<br />
エラーじゃなかった場合、つまり文字列が見つかった場合は、MID関数でA列から文字列を抜き出すというふうになっています。<br />
抜き出す位置は、A列から、「=」を探して、その次の文字から、A列の最後の文字まで、としました。</p>
<p>なぜ質問者さんが「自動」という文字で探そうとしているのかがよくわからないのですが。。。(^^;</p>
<p>なお、A列に「自動車」と「自動二輪」が両方含まれている場合や、「=」が入っていない、また「=自動車=マーチ」みたいな感じで値が入っていた場合は、この式ではだめですね。</p>
<p>こちらにアップしておきます→<a href="http://www.simple-sys.com/blog/wp-content/uploads/2009/03/vbastudy_27.xls">vbastudy_27.xls</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simple-sys.com/blog/2009/03/13/351/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBAでスクレイピングして画像をダウンロードしてシートに貼り付ける</title>
		<link>http://www.simple-sys.com/blog/2008/04/26/338/</link>
		<comments>http://www.simple-sys.com/blog/2008/04/26/338/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 11:30:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[VBAのお勉強]]></category>

		<guid isPermaLink="false">http://www.simple-sys.com/blog/?p=338</guid>
		<description><![CDATA[

http://q.hatena.ne.jp/1209185751
とりあえず、

Excelのシート上のボタンを押すと、指定したURLのページの天気の画像と、最高気温を取ってみたいと思います。
ここんとこよく取り上げ [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p><a href="http://q.hatena.ne.jp/1209185751" target="_blank">http://q.hatena.ne.jp/1209185751</a></p>
<p>とりあえず、</p>
<p><img class="alignnone size-full wp-image-344" title="338-00" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/338-00.jpg" alt="" width="347" height="145" /></p>
<p>Excelのシート上のボタンを押すと、指定したURLのページの天気の画像と、最高気温を取ってみたいと思います。</p>
<p>ここんとこよく取り上げてる「スクレイピング」ですね。<br />
<span id="more-338"></span><br />
こないだやったのは、</p>
<p><a title="Permanent Link to VBAのお勉強　住所の文字列→緯度・経度を求める" rel="bookmark" href="http://www.simple-sys.com/blog/2008/04/06/301" target="_blank">VBAのお勉強　住所の文字列→緯度・経度を求める</a></p>
<p>これは文字から緯度・経度を取ってくる、ってものでした。</p>
<p>今回は、固定のページから指定した部分を抜き出してくる、ということで前よりは簡単そうです。</p>
<p>ただ、「画像を抜き出したい」とのことなので、それはこの前とはちょっと違いますね。</p>
<p>まず、HTMLのソースを取ってきてみます。</p>
<div class="igBar"><span id="lvb-14"><a href="#" onclick="javascript:showCodeTxt('vb-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Visual Basic:</span>
<div id="vb-14">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Sub</span> test<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> oHttp <span style="color: #b1b100;">As</span> Object</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Set</span> oHttp = <span style="color: #b1b100;">CreateObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"MSXML2.XMLHTTP"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; oHttp.<span style="color: #b1b100;">Open</span> <span style="color: #ff0000;">"GET"</span>, <span style="color: #ff0000;">"http://weather.livedoor.com/area/20/72.html"</span>, <span style="color: #b1b100;">False</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; oHttp.<span style="color: #66cc66;">Send</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Debug.<span style="color: #b1b100;">Print</span> oHttp.<span style="color: #66cc66;">responseText</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>こないだのYahoo!のトップを取ってくるのと同じですね。URLが違うだけです。</p>
<p>実行してみると、</p>
<p><img class="alignnone size-full wp-image-340" title="338-011" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/338-011.jpg" alt="" width="424" height="255" /></p>
<p>ん、取れてるようです（＾＾）</p>
<p>天気と最高気温の部分はどこかな？</p>
<div class="igBar"><span id="lhtml-15"><a href="#" onclick="javascript:showCodeTxt('html-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-15">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">&lt;table</span></a> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">cellpadding</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">cellspacing</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">align</span>=<span style="color: #ff0000;">"center"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"100%"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"title"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/small.html"><span style="color: #000000; font-weight: bold;">&lt;small&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/strong.html"><span style="color: #000000; font-weight: bold;">&lt;strong&gt;</span></a></span>今日の天気<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/strong&gt;</span></span> - 4月26日(<span style="color: #009900;"><a href="http://december.com/html/4/element/font.html"><span style="color: #000000; font-weight: bold;">&lt;font</span></a> <span style="color: #000066;">color</span>=<span style="color: #ff0000;">'navy'</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>土<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/font&gt;</span></span>)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/small&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">&lt;table</span></a> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">cellpadding</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">cellspacing</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">align</span>=<span style="color: #ff0000;">"center"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"tableline"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">rowspan</span>=<span style="color: #ff0000;">"4"</span> <span style="color: #000066;">align</span>=<span style="color: #ff0000;">"center"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"tdline"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"20%"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">"margin-bottom:5px;"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/img.html"><span style="color: #000000; font-weight: bold;">&lt;img</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"http://image.weather.livedoor.com/img/icon/10.gif"</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">"曇時々雨"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">&lt;br</span></a> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/small.html"><span style="color: #000000; font-weight: bold;">&lt;small&gt;</span></a></span>曇時々雨<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/small&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">&lt;table</span></a> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">cellpadding</span>=<span style="color: #ff0000;">"1"</span> <span style="color: #000066;">cellspacing</span>=<span style="color: #ff0000;">"0"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">&lt;span</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"maxtemp"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/small.html"><span style="color: #000000; font-weight: bold;">&lt;small&gt;</span></a></span>最高気温<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/small&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">&lt;span</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"maxtemp"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/small.html"><span style="color: #000000; font-weight: bold;">&lt;small&gt;</span></a></span>15℃<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/small&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">align</span>=<span style="color: #ff0000;">"right"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">&lt;span</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"maxtemp"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/small.html"><span style="color: #000000; font-weight: bold;">&lt;small&gt;</span></a></span>前日差<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/small&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">&lt;span</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"maxtemp"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/small.html"><span style="color: #000000; font-weight: bold;">&lt;small&gt;</span></a></span>(+3)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/small&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>このあたりですね。</p>
<p>まず、簡単なほう、最高気温のほうから取ってみます。</p>
<p>ソースを見てみると、</p>
<p>&lt;small&gt;15℃&lt;/small&gt;</p>
<p>の部分の「℃」の文字が一番最初に出てくるのが、この最高気温の部分のようです。</p>
<p>ということは、ソースの中から「℃」を探して、その前の数字の部分（&gt;の後ろのから℃の前まで）が最高気温、ということになりそうです。</p>
<p>「℃」の位置を求めるには、いつものInstrでよさげです。</p>
<div class="igBar"><span id="lvb-16"><a href="#" onclick="javascript:showCodeTxt('vb-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Visual Basic:</span>
<div id="vb-16">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Sub</span> test<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> oHttp <span style="color: #b1b100;">As</span> Object</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> getSource <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Set</span> oHttp = <span style="color: #b1b100;">CreateObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"MSXML2.XMLHTTP"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; oHttp.<span style="color: #b1b100;">Open</span> <span style="color: #ff0000;">"GET"</span>, <span style="color: #ff0000;">"http://weather.livedoor.com/area/20/72.html"</span>, <span style="color: #b1b100;">False</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; oHttp.<span style="color: #66cc66;">Send</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; getSource = oHttp.<span style="color: #66cc66;">responseText</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Debug.<span style="color: #b1b100;">Print</span> <span style="color: #b1b100;">InStr</span><span style="color:#006600; font-weight:bold;">&#40;</span>getSource, <span style="color: #ff0000;">"℃"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>実行してみると</p>
<p><img class="alignnone size-full wp-image-341" title="338-02" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/338-02.jpg" alt="" width="75" height="41" /></p>
<p>実行するときの状況によって値は異なると思いますが、私が取り込んだ時点では7954文字目に「℃」があるようです。</p>
<p>次は、その前の 「&gt;」の位置を調べなければいけないんですが。。。</p>
<p>「&gt;」は、ソースの中にいっぱいありますから、単純に　Instr　では求められません。</p>
<p>この場合、後ろから文字を探す、InStrRevが使えそうです。</p>
<p>最初から「℃」までを抜き出した文字列を作り、その文字の後ろから「&gt;」を探す、って感じですね。</p>
<div class="igBar"><span id="lvb-17"><a href="#" onclick="javascript:showCodeTxt('vb-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Visual Basic:</span>
<div id="vb-17">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Sub</span> test<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> oHttp <span style="color: #b1b100;">As</span> Object</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> getSource <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> nukidashi <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> saikoukion <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Set</span> oHttp = <span style="color: #b1b100;">CreateObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"MSXML2.XMLHTTP"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; oHttp.<span style="color: #b1b100;">Open</span> <span style="color: #ff0000;">"GET"</span>, <span style="color: #ff0000;">"http://weather.livedoor.com/area/20/72.html"</span>, <span style="color: #b1b100;">False</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; oHttp.<span style="color: #66cc66;">Send</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; getSource = oHttp.<span style="color: #66cc66;">responseText</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nukidashi = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>getSource, <span style="color: #cc66cc;color:#800000;">1</span>, <span style="color: #b1b100;">InStr</span><span style="color:#006600; font-weight:bold;">&#40;</span>getSource, <span style="color: #ff0000;">"℃"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Debug.<span style="color: #b1b100;">Print</span> <span style="color: #b1b100;">InStrRev</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #ff0000;">"&gt;"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; saikoukion = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #b1b100;">InStrRev</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #ff0000;">"&gt;"</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Debug.<span style="color: #b1b100;">Print</span> saikoukion</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
nukidashiという変数に、先頭から「℃」までの文字列を代入して、</p>
<p>InStrRev(nukidashi, "&gt;")　でnukidashiの後ろから「&gt;」を探しています。</p>
<p>saikoukionに、「&gt;」の次の文字以降の文字列を取ってくる、という風にしています。</p>
<p>実行してみると、</p>
<p><img class="alignnone size-full wp-image-342" title="338-03" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/338-03.jpg" alt="" width="74" height="55" /></p>
<p>ん、取れました（＾＾）</p>
<p>後は、これをセルに代入すればいいですね。これは後でまとめてやります。</p>
<p>次、天気なんですけど。「画像を取りたい」ってことなので、流れとしては、画像をダウンロードして、</p>
<p>その画像をシートに貼り付ける、って感じでいいのかな？</p>
<p>まずソースの中から画像の部分を探してみます。</p>
<div class="igBar"><span id="lhtml-18"><a href="#" onclick="javascript:showCodeTxt('html-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-18">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">&lt;table</span></a> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">cellpadding</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">cellspacing</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">align</span>=<span style="color: #ff0000;">"center"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"100%"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"title"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/small.html"><span style="color: #000000; font-weight: bold;">&lt;small&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/strong.html"><span style="color: #000000; font-weight: bold;">&lt;strong&gt;</span></a></span>今日の天気<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/strong&gt;</span></span> - 4月26日(<span style="color: #009900;"><a href="http://december.com/html/4/element/font.html"><span style="color: #000000; font-weight: bold;">&lt;font</span></a> <span style="color: #000066;">color</span>=<span style="color: #ff0000;">'navy'</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>土<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/font&gt;</span></span>)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/small&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/td&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/tr&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/table&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">&lt;table</span></a> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">cellpadding</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">cellspacing</span>=<span style="color: #ff0000;">"0"</span> <span style="color: #000066;">align</span>=<span style="color: #ff0000;">"center"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"tableline"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">&lt;tr&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">&lt;td</span></a> <span style="color: #000066;">rowspan</span>=<span style="color: #ff0000;">"4"</span> <span style="color: #000066;">align</span>=<span style="color: #ff0000;">"center"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"tdline"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"20%"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">"margin-bottom:5px;"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/img.html"><span style="color: #000000; font-weight: bold;">&lt;img</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"http://image.weather.livedoor.com/img/icon/10.gif"</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">"曇時々雨"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000; font-weight: bold;">&lt;br</span></a> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><a href="http://december.com/html/4/element/small.html"><span style="color: #000000; font-weight: bold;">&lt;small&gt;</span></a></span>曇時々雨<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/small&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>この辺ですね。この「&lt;img src=・・・・&gt;」の部分を取ってくればいいんですが。</p>
<p>ソース全体でみれば、&lt;img&gt;タグは他にもいっぱいあるので、簡単には探せませんね。</p>
<p>ということで、この近辺をなんとか抜き出して、その中で&lt;img&gt;を抜き出す、ってことで。</p>
<p>全体のソースをみると、「今日の天気」という文字列は、この部分で初めて出てくるようです。</p>
<p>ということは、全体のソースから「今日の天気」を探し、そこ以降の文字列を抜き出し、その中で最初に出てくる&lt;img&gt;を抜き出せばよさげです。</p>
<p>こんな感じになります。</p>
<div class="igBar"><span id="lvb-19"><a href="#" onclick="javascript:showCodeTxt('vb-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Visual Basic:</span>
<div id="vb-19">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Sub</span> test<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> oHttp <span style="color: #b1b100;">As</span> Object</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> getSource <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> nukidashi <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> saikoukion <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Set</span> oHttp = <span style="color: #b1b100;">CreateObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"MSXML2.XMLHTTP"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; oHttp.<span style="color: #b1b100;">Open</span> <span style="color: #ff0000;">"GET"</span>, <span style="color: #ff0000;">"http://weather.livedoor.com/area/20/72.html"</span>, <span style="color: #b1b100;">False</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; oHttp.<span style="color: #66cc66;">Send</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; getSource = oHttp.<span style="color: #66cc66;">responseText</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'最高気温を取ってきます。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nukidashi = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>getSource, <span style="color: #cc66cc;color:#800000;">1</span>, <span style="color: #b1b100;">InStr</span><span style="color:#006600; font-weight:bold;">&#40;</span>getSource, <span style="color: #ff0000;">"℃"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; saikoukion = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #b1b100;">InStrRev</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #ff0000;">"&gt;"</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'「今日の天気」以降の文字列を抜き出します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nukidashi = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>getSource, <span style="color: #b1b100;">InStr</span><span style="color:#006600; font-weight:bold;">&#40;</span>getSource, <span style="color: #ff0000;">"今日の天気"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'抜き出した文字列の中で、最初の　「　&lt;img　」以降を抜き出します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nukidashi = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #b1b100;">InStr</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #ff0000;">"&lt;img"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'抜き出した文字列の中で、最初の　「　&quot;　」の次の文字以降を抜き出します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nukidashi = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #b1b100;">InStr</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #ff0000;">""</span><span style="color: #ff0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'抜き出した文字列の中で、最初の　「　&quot;　」の前の文字までを抜き出します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nukidashi = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #cc66cc;color:#800000;">1</span>, <span style="color: #b1b100;">InStr</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #ff0000;">""</span><span style="color: #ff0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Debug.<span style="color: #b1b100;">Print</span> nukidashi</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>画像のURLを取ってくるところまで書いちゃいましたが、</p>
<p>・まず、「今日の天気」以降を抜き出します。</p>
<p>・次に、その文字列から「&lt;img 」を探し、それ以降の文字列を抜き出します。</p>
<p>・次に、その文字列から　「 " 」（src="の部分です）を探し、その文字の次の文字以降の文字列を抜き出します。</p>
<p>・最後に、その文字列から 「"」（src=の終わりの"です）を探し、その文字の前の文字までを抜き出します。</p>
<p>実行すると、こんな感じ。</p>
<p><img class="alignnone size-full wp-image-343" title="338-04" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/338-04.jpg" alt="" width="365" height="61" /></p>
<p>取れました（＾＾）</p>
<p>後は、このURLの画像を貼り付ければいいんですが、、、画像のダウンロードってどうやるのか？</p>
<p><a href="http://search.yahoo.co.jp/search?p=excel+vba+%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89&amp;ei=UTF-8&amp;fr=slv1-ytpprn&amp;x=wrt" target="_blank">「excel vba ファイルをダウンロード」</a></p>
<p>で検索して見つかった、<a href="http://makotowatana.ld.infoseek.co.jp/vba.html" target="_blank">こちらのページ</a>からリンクされていた<a href="http://www.ken3.org/vba/backno/vba120.html" target="_blank">、こちらのページ</a>の説明がわかりやすかったです。</p>
<p>ということで、こんな感じ。</p>
<div class="igBar"><span id="lvb-20"><a href="#" onclick="javascript:showCodeTxt('vb-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Visual Basic:</span>
<div id="vb-20">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080;">'URLDownloadToFile API from URLMON.</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Declare</span> <span style="color: #b1b100;">Function</span> URLDownloadToFile Lib <span style="color: #ff0000;">"urlmon"</span> Alias _</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">"URLDownloadToFileA"</span> <span style="color:#006600; font-weight:bold;">&#40;</span>ByVal pCaller <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Long</span>, ByVal szURL <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span>, ByVal _</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">szFileName <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span>, ByVal dwReserved <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Long</span>, ByVal lpfnCB <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Long</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Long</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Sub</span> CommandButton1_Click<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> oHttp <span style="color: #b1b100;">As</span> Object</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> getSource <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> nukidashi <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> saikoukion <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> strURL <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> strFNAME <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> returnValue</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Set</span> oHttp = <span style="color: #b1b100;">CreateObject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">"MSXML2.XMLHTTP"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; oHttp.<span style="color: #b1b100;">Open</span> <span style="color: #ff0000;">"GET"</span>, <span style="color: #ff0000;">"http://weather.livedoor.com/area/20/72.html"</span>, <span style="color: #b1b100;">False</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; oHttp.<span style="color: #66cc66;">Send</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; getSource = oHttp.<span style="color: #66cc66;">responseText</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'最高気温を取ってきます。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nukidashi = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>getSource, <span style="color: #cc66cc;color:#800000;">1</span>, <span style="color: #b1b100;">InStr</span><span style="color:#006600; font-weight:bold;">&#40;</span>getSource, <span style="color: #ff0000;">"℃"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; saikoukion = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #b1b100;">InStrRev</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #ff0000;">"&gt;"</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'シートに代入します</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">1</span>, <span style="color: #cc66cc;color:#800000;">4</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> = saikoukion</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'「今日の天気」以降の文字列を抜き出します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nukidashi = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>getSource, <span style="color: #b1b100;">InStr</span><span style="color:#006600; font-weight:bold;">&#40;</span>getSource, <span style="color: #ff0000;">"今日の天気"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'抜き出した文字列の中で、最初の　「　&lt;img　」以降を抜き出します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nukidashi = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #b1b100;">InStr</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #ff0000;">"&lt;img"</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'抜き出した文字列の中で、最初の　「　&quot;　」の次の文字以降を抜き出します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nukidashi = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #b1b100;">InStr</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #ff0000;">""</span><span style="color: #ff0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span> + <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'抜き出した文字列の中で、最初の　「　&quot;　」の前の文字までを抜き出します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; strURL = <span style="color: #b1b100;">Mid</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #cc66cc;color:#800000;">1</span>, <span style="color: #b1b100;">InStr</span><span style="color:#006600; font-weight:bold;">&#40;</span>nukidashi, <span style="color: #ff0000;">""</span><span style="color: #ff0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span> - <span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'ダウンロードする画像をルートのtenki.gifにします。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'画像上書きしますので、注意してください。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; strFNAME = <span style="color: #ff0000;">"\tenki.gif"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'URLDownloadToFile API をコールする</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; returnValue = URLDownloadToFile<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span>, strURL, strFNAME, <span style="color: #cc66cc;color:#800000;">0</span>, <span style="color: #cc66cc;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'画像を挿入したいセルを選択します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">1</span>, <span style="color: #cc66cc;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Select</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'ダウンロードした画像を今のセルの位置に挿入します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Pictures</span>.<span style="color: #66cc66;">Insert</span> Filename:=<span style="color: #ff0000;">"\tenki.gif"</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>もう、全部作っちゃいました（＾＾；）。コメントが入ってますので、それを見ればどこで何をやってるかは分かると思います。</p>
<p>このファイルがあるドライブのルートディレクトリにtenki.gifという名前で画像を保存して、それをシートに貼り付ける、というふうになっています。なので、tenki.gifというファイルがあったら、上書きされちゃいますので実行するときは注意してください。</p>
<p>実行すると、こんな感じ</p>
<p><img class="alignnone size-full wp-image-345" title="338-05" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/338-05.jpg" alt="" width="374" height="143" /></p>
<p>ん、できました（＾＾）</p>
<p>ここに置いておきます→<a href="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/vbastudy_26.xls">vbastudy_26</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simple-sys.com/blog/2008/04/26/338/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>注文メールの内容をサーバーから受信しExcelに取り込む仕組みのサンプル</title>
		<link>http://www.simple-sys.com/blog/2008/04/14/337/</link>
		<comments>http://www.simple-sys.com/blog/2008/04/14/337/#comments</comments>
		<pubDate>Mon, 14 Apr 2008 03:37:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[プログラム]]></category>

		<guid isPermaLink="false">http://www.simple-sys.com/blog/?p=337</guid>
		<description><![CDATA[

ショッピングカートやネットショッピングモールなどからお客様からの注文内容がメールで送られてくるような時、その内容をExcelなどにコピー＆ペーストなどで貼り付けている方もいらっしゃると思います。
Excel＋αのソフ [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>ショッピングカートやネットショッピングモールなどからお客様からの注文内容がメールで送られてくるような時、その内容をExcelなどにコピー＆ペーストなどで貼り付けている方もいらっしゃると思います。</p>
<p>Excel＋αのソフトで、メールを自動的に取り込んで、エクセルのセルに貼り付ける仕組みのサンプルをつくってみました。</p>
<p><a href="http://www.simple-sys.com/blog/mailtorikomi/" target="_blank">こちらのページ</a>からどうぞ</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simple-sys.com/blog/2008/04/14/337/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Excelで１行残して重複行を削除(複数の項目でチェック)</title>
		<link>http://www.simple-sys.com/blog/2008/04/08/321/</link>
		<comments>http://www.simple-sys.com/blog/2008/04/08/321/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 03:07:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[VBAのお勉強]]></category>

		<guid isPermaLink="false">http://www.simple-sys.com/blog/?p=321</guid>
		<description><![CDATA[

前回の続きです。

↓

B列、C列の両方の項目を見て、重複しているものは最初のものを残して削除する、という感じです。

プログラムです。
PLAIN TEXT
Visual Basic:




Sub test&#038; [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p><a href="http://www.simple-sys.com/blog/2008/04/07/314/" target="_blank">前回</a>の続きです。</p>
<p><img class="alignnone size-full wp-image-322" title="321-01" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/321-01.jpg" alt="" width="284" height="296" /></p>
<p>↓</p>
<p><img class="alignnone size-full wp-image-323" title="321-02" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/321-02.jpg" alt="" width="282" height="243" /></p>
<p>B列、C列の両方の項目を見て、重複しているものは最初のものを残して削除する、という感じです。<br />
<span id="more-321"></span><br />
プログラムです。</p>
<div class="igBar"><span id="lvb-22"><a href="#" onclick="javascript:showCodeTxt('vb-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Visual Basic:</span>
<div id="vb-22">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Sub</span> test<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> lastgyou <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> i <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> j <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> checkataiB <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> checkataiC <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'B列の最終行を求めます。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; lastgyou = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>ActiveSheet.<span style="color: #66cc66;">Rows</span>.<span style="color: #b1b100;">Count</span>, <span style="color: #cc66cc;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #b1b100;">End</span><span style="color:#006600; font-weight:bold;">&#40;</span>xlUp<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Row</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'1行目から最終行の前まで繰り返します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">For</span> i = <span style="color: #cc66cc;color:#800000;">1</span> <span style="color: #b1b100;">To</span> lastgyou - <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">'チェックする値を、checkataiB、checkataiCに代入します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; checkataiB = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>i, <span style="color: #cc66cc;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; checkataiC = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>i, <span style="color: #cc66cc;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">'今見てる行から、下をチェックします。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">For</span> j = i + <span style="color: #cc66cc;color:#800000;">1</span> <span style="color: #b1b100;">To</span> lastgyou</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">'もし、値が同じであれば、</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">If</span> checkataiB = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>j, <span style="color: #cc66cc;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> <span style="color: #b1b100;">And</span> checkataiC = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>j, <span style="color: #cc66cc;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> <span style="color: #b1b100;">Then</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">'その行を削除します</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Rows</span><span style="color:#006600; font-weight:bold;">&#40;</span>j<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Delete</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">'最終行が１行減ったのでlastgyouの値を減らします。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lastgyou = lastgyou - <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">'チェックしている行を１行前に戻します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j - <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">Next</span> j</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Next</span> i</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>前回のプログラムとそんなに変わりません。チェックする項目を変数２つに入れ、その値を両方ともチェックしていくという方法ですね。</p>
<p>実行すると、こんな感じ。<br />
<img class="alignnone size-medium wp-image-323" title="321-02" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/321-02.jpg" alt="" width="282" height="243" /></p>
<p>ん、うまいこと消えました（＾＾）ここに置いておきます。→<a href="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/vbastudy_25.xls">vbastudy_25</a></p>
<p>こんな感じで、チェックしたい項目が増えれば、同じように変数に代入して、その値をチェックする、、、とすればよいですね。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simple-sys.com/blog/2008/04/08/321/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBAのお勉強　Excelで１行残して重複行を削除</title>
		<link>http://www.simple-sys.com/blog/2008/04/07/314/</link>
		<comments>http://www.simple-sys.com/blog/2008/04/07/314/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 14:55:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[VBAのお勉強]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[重複行]]></category>

		<guid isPermaLink="false">http://www.simple-sys.com/blog/?p=314</guid>
		<description><![CDATA[

このブログのリファラーを見ていると、あいかわらず「VBA Excel 重複行」で検索されてくる方が多いですね。
みなさん、そんなに重複行をどうにかしたいのでしょうか？（＾＾；）
重複行について、今までに書いたのは以下 [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>このブログのリファラーを見ていると、あいかわらず「<a href="http://search.yahoo.co.jp/search?fr=slv1-ytpprn&amp;p=VBA%20Excel%a1%a1%bd%c5%ca%a3%b9%d4" target="_blank">VBA Excel 重複行</a>」で検索されてくる方が多いですね。</p>
<p>みなさん、そんなに重複行をどうにかしたいのでしょうか？（＾＾；）</p>
<p>重複行について、今までに書いたのは以下の記事です。</p>
<p><a rel="bookmark" href="http://www.simple-sys.com/blog/2008/03/13/43" target="_blank">VBAのお勉強  Excelで重複行を探す</a></p>
<p>こちらは、複数の列で重複している値を探す、というものでした。</p>
<p><a rel="bookmark" href="http://www.simple-sys.com/blog/2008/03/27/160" target="_blank">VBAのお勉強　VBAでExcelの重複した行を探して表示</a></p>
<p>こちらは、一つの列の中で重複している値を探す、というものでした。</p>
<p>ただ私の経験で、今までデータの重複行、うんぬんを考えるとき、「重複行をどうしたいのか？」で考えると、一番多いのは、</p>
<p><img class="alignnone size-full wp-image-315" title="314-01" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/314-01.jpg" alt="" width="236" height="299" /></p>
<p>こんなデータがあったとき、B列で重複している行を１行だけ残して、削除してしまう、つまり、</p>
<p><img class="alignnone size-full wp-image-316" title="314-02" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/314-02.jpg" alt="" width="217" height="192" /></p>
<p>こうしてしまいたい、という事のような気がします。違いますかね？（＾＾；）</p>
<p>名簿なんかで「同じ人がいたら１行残して後は消す」みたいな処理、多いと思うんですけど。</p>
<p><span id="more-314"></span><br />
んで、こういうことをするには、「フィルタ」とかを使うのでしょうけど、あの機能って、いまいちよく分からないんですよね。。。</p>
<p>重複した行を「見えなくする」事や、重複しないデータにして、別の位置に抽出して抜き出す、のは、なんとなく出来たんですが。</p>
<p>あとは並べ替えて、IFを使って前の行と同じ値だったらフラグを立てて、その行を消す。とか。</p>
<p>・・・なんか、余計な項目を作ったり、別のところに書き出したり、並べ替えたりするの、めんどくさいんですよね（＾＾；）</p>
<p>自分がやりたいのは、「重複してる行を１行残して、削除する」という事です。</p>
<p>これってエクセルの機能で一発でできないんでしょうか？（＾＾；）</p>
<blockquote><p>
08/4/10 追記<br />
Excel2007には、これを実現させる機能があるようですね。<br />
<a href="http://excel2007.officetanaka.com/?eid=404347" target="_blank">こちらのサイト</a>にその機能の詳細がのっています
</p></blockquote>
<p>ということで、VBAで書いてみます。</p>
<p>今回はB列の値をみて、</p>
<ul>
<li>重複していない行は、そのまま残す</li>
<li>重複している行は、一番先頭の行を残して、残りは削除する</li>
</ul>
<p>という条件でやってみます。</p>
<div class="igBar"><span id="lvb-24"><a href="#" onclick="javascript:showCodeTxt('vb-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Visual Basic:</span>
<div id="vb-24">
<div class="vb">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">Sub</span> test<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> lastgyou <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> i <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> j <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> checkatai <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'B列の最終行を求めます。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; lastgyou = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>ActiveSheet.<span style="color: #66cc66;">Rows</span>.<span style="color: #b1b100;">Count</span>, <span style="color: #cc66cc;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #b1b100;">End</span><span style="color:#006600; font-weight:bold;">&#40;</span>xlUp<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Row</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080;">'1行目から最終行の前まで繰り返します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">For</span> i = <span style="color: #cc66cc;color:#800000;">1</span> <span style="color: #b1b100;">To</span> lastgyou - <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">'チェックする値を、checkataiに代入します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; checkatai = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>i, <span style="color: #cc66cc;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">'今見てる行から、下をチェックします。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">For</span> j = i + <span style="color: #cc66cc;color:#800000;">1</span> <span style="color: #b1b100;">To</span> lastgyou</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">'もし、値が同じであれば、</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">If</span> checkatai = ActiveSheet.<span style="color: #66cc66;">Cells</span><span style="color:#006600; font-weight:bold;">&#40;</span>j, <span style="color: #cc66cc;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Value</span> <span style="color: #b1b100;">Then</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">'その行を削除します</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ActiveSheet.<span style="color: #66cc66;">Rows</span><span style="color:#006600; font-weight:bold;">&#40;</span>j<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color: #66cc66;">Delete</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">'最終行が１行減ったのでlastgyouの値を減らします。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lastgyou = lastgyou - <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">'チェックしている行を１行前に戻します。</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; j = j - <span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">Next</span> j</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">Next</span> i</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>先頭から１行ずつ、最後の行の前まで見ていきます。</p>
<p>今見てる行の次の行以下を最後の行まで探し、もし今見てる行と同じ値があったら、見つけたほうの行を削除する、という考えかたです。人間が手作業で削除するのと同じですね。</p>
<p>削除した場合、全体の行数が減るのと、次にチェックすべき行（プログラムの j の変数）が１行上に来るので、それも減らす、という感じです。</p>
<p>実行してみると、、、</p>
<p><img class="alignnone size-full wp-image-317" title="314-03" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/314-03.jpg" alt="" width="210" height="188" /></p>
<p>ん、重複行がなくなりました（＾＾）</p>
<p>とりあえず、ここに置いときます。→<a href="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/vbastudy_24.xls">vbastudy_24</a><br />
今回は重複をチェックする対象が、B列だけでした。</p>
<p>これを、</p>
<p><img class="alignnone size-full wp-image-319" title="314-04" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/314-04.jpg" alt="" width="283" height="300" /></p>
<p>↓</p>
<p><img class="alignnone size-full wp-image-320" title="314-05" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/314-05.jpg" alt="" width="284" height="243" /></p>
<p>といったように「住所」「名前」の両方が重複している場合削除する、といったように、複数の列をチェックの対象にすることもプログラムを変更すれば可能です。これは次回にやります。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simple-sys.com/blog/2008/04/07/314/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBAのお勉強　住所の文字列→緯度・経度を求める</title>
		<link>http://www.simple-sys.com/blog/2008/04/06/301/</link>
		<comments>http://www.simple-sys.com/blog/2008/04/06/301/#comments</comments>
		<pubDate>Sun, 06 Apr 2008 00:55:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[VBAのお勉強]]></category>

		<guid isPermaLink="false">http://www.simple-sys.com/blog/?p=301</guid>
		<description><![CDATA[

　http://q.hatena.ne.jp/1207343267
例えば、

こんな、Excelファイルがあった時、B列に緯度、C列に経度を入れる。。。
緯度・経度を求めるには、例えばYahoo!さんなんかでは、A [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>　<a href="http://q.hatena.ne.jp/1207343267" target="_blank">http://q.hatena.ne.jp/1207343267</a></p>
<p>例えば、</p>
<p><img class="alignnone size-full wp-image-302" title="301-01" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/301-01.jpg" alt="" width="335" height="171" /></p>
<p>こんな、Excelファイルがあった時、B列に緯度、C列に経度を入れる。。。</p>
<p>緯度・経度を求めるには、例えばYahoo!さんなんかでは、APIが公開されてます。</p>
<p><a href="http://developer.yahoo.co.jp/map/localsearch/V1/localsearch.html" target="_blank">ローカルサーチAPI</a><br />
こちらを使えば、住所の文字列で問い合わせれば、結果がXMLで返ってきます。</p>
<p>その中に緯度・経度も含まれますので、そこからうまく抜き出せば、おっけいですね。</p>
<p>Googleさんでも、APIがあるみたいです。</p>
<p><a href="http://googlemapsapi.blogspot.com/2006/12/japanese-address-and-placename-support.html" target="_blank">Google Maps API</a><br />
で、やはり、同じようにXMLで返ってくる？ようです。</p>
<p>これらを使えば、うまく出来そう（＾＾）、、、なんですが。<br />
<span id="more-301"></span><br />
ちょっと気になっているのが、例えば、Yahoo!さんの場合、<br />
<a href="http://developer.yahoo.co.jp/map/" target="_blank">http://developer.yahoo.co.jp/map/</a></p>
<p>のページによると、Yahoo!地図情報Webサービスの利用について</p>
<ul>
<li>限られた人、コンピュータによるアクセスのみ認めているサイトでのご使用</li>
<li>企業、官公庁その他の団体におけるイントラネット内でのご使用</li>
<li>地図の使用によりユーザーから利益を得ていると認められるサイトでのご使用</li>
</ul>
<p>ってあるんですよね。。。</p>
<p>これって、このAPIを使って、住所→緯度経度を求めるプログラムを作った場合、その仕組みはおそらくローカルのネットワークから使うであろう物（外部にこの仕組みを公開するわけではない）だと思いますので、規約に違反しないのかな？<br />
<a href="http://developer.yahoo.co.jp/terms/" target="_blank">http://developer.yahoo.co.jp/terms/</a>の利用規約を見てみても、（太字はこちらでつけました。）</p>
<ul>利用者は、Yahoo! JAPANのAPI に関するコメント、ノウハウ、方法論、プロシジャ、技術、データや<strong>Yahoo! JAPANのAPIを使用して開発したアプリケーションを</strong>、Yahoo!デベロッパーネットワークのコミュニティーに掲載するなど<strong>不特定多数の他の利用者がアクセスできるようにしなければならず</strong>、これをもって、Yahoo! JAPANに対して、利用者に対する通知および利用者の権利表示をすることなく、日本の国内外において、無償で非独占的にそれらを使用する（複製、公開、送信、頒布、譲渡、貸与、翻訳、翻案を含む）権利を許諾（サブライセンス権を含む）したものとみなします。また、利用者は、Yahoo! JAPANのAPI に関するコメント、ノウハウ、方法論、プロシジャ、技術、データやYahoo! JAPANのAPIを使用して開発したアプリケーションについて、著作者人格権を行使しないものとします。</ul>
<p>（＾＾；）難しい事書いてありますが、ようするに、</p>
<p>「APIを使ったアプリケーションは、外部から誰もが使える仕組みにしないと駄目」</p>
<p>っていってるような気がします。</p>
<p>最終的にこの機能を用いて作成した住所と地図が入ったWebページを公開することにはなりますが、、、<br />
この仕組み自体を公開しないと駄目なんじゃないかな？</p>
<p>もちろんWebサーバー上で、住所の文字列をCGIに渡して、そこからAPIを呼んで結果のXMLを取り込み、そこから地図を出す。みたいな流れであれば、全く問題ない使い方だとは思いますが。。。</p>
<p>これは、Googleさんでも同じ？なのかな？</p>
<p><a href="http://code.google.com/intl/ja/apis/maps/signup.html" target="_blank">http://code.google.com/intl/ja/apis/maps/signup.html</a> によると、やはり、</p>
<blockquote><p><strong>エンドユーザーが自由にアクセスできるサービスを提供してください。</strong></p></blockquote>
<p>ってあるんですよね。。。</p>
<p>というわけで、Excel→API→Excelって流れは、なんとなくまずいような気がします。（実際はどうだか分かりませんが）</p>
<blockquote><p>
09/05/12追記<br />
<a target="_blank" href="http://www.atmarkit.co.jp/fwcr/rensai2/google_int_02/01.html">こちらの記事</a>に、googleさんの利用について詳細な内容があります。<br />
誰からもアクセスできる事、デスクトップアプリケーションの場合はそのアプリケーションが誰でも利用できること、って事でいいのかな？
</p></blockquote>
<p>Yahoo!さんの場合、<a href="http://www.alpsmap.jp/asp/api.html" target="_blank">http://www.alpsmap.jp/asp/api.html</a>で同等のサービスで有料のものはあります。<br />
Googleさんの場合も、<a href="http://www.google.com/enterprise/maps/" target="_blank">http://www.google.com/enterprise/maps/</a>で同じようなことが出来るようです。</p>
<p>これらを使えば、もちろん問題はないでしょう。</p>
<p>。</p>
<p>。</p>
<p>。</p>
<p>といって、、、これであきらめちゃうのもなぁ。</p>
<p><a href="http://map.yahoo.co.jp/" target="_blank">http://map.yahoo.co.jp/</a>から、「東京都新宿区西新宿二丁目８番１号」で検索すれば、</p>
<p><img class="alignnone size-full wp-image-303" title="301-02" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/301-02.jpg" alt="" width="426" height="172" /></p>
<p>って、出ます。この検索結果の「<a href="http://map.yahoo.co.jp/pl?p=%C5%EC%B5%FE%C5%D4%BF%B7%BD%C9%B6%E8%C0%BE%BF%B7%BD%C9%C6%F3%C3%FA%CC%DC%A3%B8%C8%D6%A3%B1%B9%E6&amp;lat=35.68627083&amp;lon=139.69494083&amp;type=&amp;gov=13104.67.2.8.1">東京都新宿区西新宿2丁目8-1</a>」のURLを見てみると、</p>
<pre class="showlongcode">　
　

http://map.yahoo.co.jp/pl?p=%C5%EC%B5%FE%C5%D4%BF%B7%BD%C9%B6%E8%C0%BE%BF%B7

%BD%C9%C6%F3%C3%FA%CC%DC%A3%B8%C8%D6%A3%B1%B9%E6&amp;
lat=35.68627083&amp;lon=139.69494083&amp;type=&amp;gov=13104.67.2.8.1
　
　</pre>
<p>・・・lat　lon　これって、緯度、経度なんですよね。この値を取ってくれば。。。</p>
<p>APIは使ってないし、公開されてる情報だからどう加工しても問題ないですよね？（＾＾；）＞Yahoo!さん。</p>
<p>というわけで、APIは使わずにYahoo!地図情報を使ってみたいと思います。</p>
<p>考え方は<a href="http://www.simple-sys.com/blog/2008/03/13/40/" target="_blank">JavaScriptとかでやってた</a>「スクレイピング」ですね。</p>
<p>まずは、VBAからインターネット上のリソースをURLを指定して取ってくる方法を調べてみます。</p>
<p>「<a href="http://search.yahoo.co.jp/search?p=VBA+WEB+HTML%E3%82%92%E5%8F%96%E5%BE%97&amp;ei=UTF-8&amp;fr=slv1-ytpprn&amp;x=wrt" target="_blank">VBA WEB HTMLを取得</a>」で検索すると、<a href="http://q.hatena.ne.jp/1183776103" target="_blank">こちらのページ</a>が見つかりました。その中に紹介されていた<a href="http://www.f3.dion.ne.jp/~element/msaccess/AcTipsVbaXMLHTTP.html" target="_blank">こちらのページ</a>がわかりやすかったです。</p>
<p>とりあえず、VBAから、Yahoo!のトップのHTMLのソースを取ってきて、イミディエイトウィンドウに表示してみます。</p>
<pre class="showlongcode">　
Sub test()
Dim oHttp As Object
Set oHttp = CreateObject("MSXML2.XMLHTTP")
oHttp.Open "GET", "http://www.yahoo.co.jp/", False
oHttp.Send
Debug.Print oHttp.responseText
End Sub</pre>
<p>実行してみると、</p>
<p><img class="alignnone size-full wp-image-304" title="301-03" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/301-03.jpg" alt="" width="457" height="392" /></p>
<p>ん、表示しきれてませんが、取れているようです（＾＾）</p>
<p>では今度はYahoo!地図情報から「東京都新宿区西新宿二丁目８番１号」で検索したときのHTMLのソースを表示してみます。</p>
<p><a href="http://map.yahoo.co.jp/" target="_blank">http://map.yahoo.co.jp/</a>から、「東京都新宿区西新宿二丁目８番１号」で検索した結果のURLは、</p>
<pre class="showlongcode">　
　

http://search.map.yahoo.co.jp/search?q=&amp;p=%C5%EC%B5%FE%C5%D4%BF%B7%BD%C9%B6

%E8%C0%BE%BF%B7%BD%C9%C6%F3%C3%FA%CC%DC%A3%B8%C8%D6%A3%B1%B9%E6
&amp;gc=&amp;rsmode=map&amp;ei=euc-jp&amp;type=　
　
　</pre>
<p>ですので、これを与えてみます。</p>
<pre class="showlongcode">Sub test()
 Dim oHttp As Object
 Set oHttp = CreateObject("MSXML2.XMLHTTP")
 oHttp.Open "GET", "http://search.map.yahoo.co.jp/search?q=&amp;p=%C5%EC%B5%FE%C5%D4%BF%B7%BD%C9%B6%E8%C0%BE%BF%B7%BD%C9%C6%F3%C3%FA%CC%DC%A3%B8%C8%D6%A3%B1%B9%E6&amp;gc=&amp;rsmode=map&amp;ei=euc-jp&amp;type=", False
 oHttp.Send
 Debug.Print oHttp.responseText
End Sub</pre>
<p>実行すると、、、長い結果のソースが取得できます。</p>
<p>ところどころに「 ? 」となっているのは、おそらく文字コードが違うからでしょうが、今回欲しい情報の部分は関係なさげです。</p>
<p><img class="alignnone size-full wp-image-305" title="301-04" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/301-04.jpg" alt="" width="454" height="75" /></p>
<p>のあたりに、</p>
<p><img class="alignnone size-full wp-image-306" title="301-05" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/301-05.jpg" alt="" width="491" height="107" /></p>
<p>ってありますね（＾＾）。この情報を抜き出せばよさそうです。</p>
<p>こういうの、抜き出すのはやっぱり正規表現を使うべき、だとは思うのですが、やはり、参照設定とかあんまり好きじゃないので（＾＾；）　泥臭い方法でやってみます。</p>
<p>といっても、取ってきたソースの中から、lat=の部分とlon=の部分を探してくるだけですから、そんなに難しくありません。</p>
<pre class="showlongcode">
Sub test()

Dim lat As String
Dim lon As String

Dim nukidashi As String

Dim oHttp As Object
Set oHttp = CreateObject("MSXML2.XMLHTTP")
oHttp.Open "GET", "http://search.map.yahoo.co.jp/search?q=&amp;p=%C5%EC%B5%FE%C5%D4%BF%B7%BD%C9%B6%E8%C0%BE%BF%B7%BD%C9%C6%F3%C3%FA%CC%DC%A3%B8%C8%D6%A3%B1%B9%E6&amp;gc=&amp;rsmode=map&amp;ei=euc-jp&amp;type=", False
oHttp.Send

'とりあえず、nukidashiに、「lat=」以降の文字列を入れます。

nukidashi = Mid(oHttp.responseText, InStr(oHttp.responseText, "lat=") + 4)

'次の「&amp;」までがlatです。

lat = Mid(nukidashi, 1, InStr(nukidashi, "&amp;") - 1)

'nukidashiを「lon=」以降の文字列にします。

nukidashi = Mid(nukidashi, InStr(nukidashi, "lon=") + 4)

'次の「&amp;」までがlonです。

lon = Mid(nukidashi, 1, InStr(nukidashi, "&amp;") - 1)

Debug.Print "緯度"; lat
Debug.Print "経度"; lon

End Sub</pre>
<p>実行してみると、</p>
<p><img class="alignnone size-full wp-image-307" title="301-06" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/301-06.jpg" alt="" width="152" height="64" /></p>
<p>ん、取れました（＾＾）</p>
<p>後は、ExcelのA列に入ってる文字列をURLに与えて、取ってきたデータを、B列、C列に戻す、って感じですね。</p>
<p>・・・って、どうやってURLを求めればいいんでしょうか？（＾＾；）<br />
「東京都新宿区西新宿二丁目８番１号」で検索した結果のURLは、</p>
<pre class="showlongcode">

http://search.map.yahoo.co.jp/search?q=&amp;

<span style="color: #ff0000;">p=%C5%EC%B5%FE%C5%D4%BF%B7%BD%C9%B6%E8%C0%BE%BF%B7%BD%C9%C6%F3%C3%FA%CC%DC%A3%B8%C8%D6%A3%B1%B9%E6</span>
&amp;gc=&amp;rsmode=map&amp;ei=euc-jp&amp;type=
　
　</pre>
<p>長いので途中で改行しましたが、この赤い部分の「p=」で始まる部分が、「東京都新宿区西新宿二丁目８番１号」を表しているようです。<br />
ということは、この文字列を作り出さないといけない、って事ですね。<br />
どうやらこの文字列は、「東京都新宿区西新宿二丁目８番１号」をeuc-jpでエンコードしたもののようです。</p>
<p><a href="http://www.tagindex.com/tool/url.html" target="_blank">こちらのページ</a>で、「東京都新宿区西新宿二丁目８番１号」で、euc-jpで変換してみると、<br />
<img class="alignnone size-full wp-image-308" title="301-07" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/301-07.jpg" alt="" /><br />
ん、確かにp=で与えている文字列になってます。</p>
<p>では、この文字を作ればいいのか、、、とはいえ、Excelって、基本的にはShift-JISなので、Shift-JISからEUCに変換しないといけませんね。</p>
<p>「<a href="http://search.yahoo.co.jp/search?fr=slv1-ytpprn&amp;p=VBA%a1%a1SJIS%20EUC%20%ca%d1%b4%b9" target="_blank">VBA　SJIS EUC 変換</a>」で検索すると、<a href="http://www.ken3.org/asp/backno/asp107.html" target="_blank">こちらのサイト</a>が見つかりました。<br />
こちらのサイトを参考に、Shift-JIS→EUCの部分を組み込んでみたいと思います。</p>
<pre class="showlongcode">Sub test()

    Dim lat As String
    Dim lon As String

    Dim nukidashi As String
    Dim eucurlencode As String

    Dim oHttp  As Object
    Set oHttp = CreateObject("MSXML2.XMLHTTP")

    eucurlencode = getEUC("東京都新宿区西新宿二丁目８番１号")

    Debug.Print "pの文字列は" + eucurlencode

    oHttp.Open "GET", "http://search.map.yahoo.co.jp/search?q=&amp;p=" + eucurlencode + "&amp;gc=&amp;rsmode=map&amp;ei=euc-jp&amp;type=", False
    oHttp.Send

    'とりあえず、nukidashiに、「lat=」以降の文字列を入れます。

    nukidashi = Mid(oHttp.responseText, InStr(oHttp.responseText, "lat=") + 4)

    '次の「&amp;」までがlatです。

    lat = Mid(nukidashi, 1, InStr(nukidashi, "&amp;") - 1)

    'nukidashiを「lon=」以降の文字列にします。

    nukidashi = Mid(nukidashi, InStr(nukidashi, "lon=") + 4)

    '次の「&amp;」までがlonです。

    lon = Mid(nukidashi, 1, InStr(nukidashi, "&amp;") - 1)

    Debug.Print "緯度"; lat
    Debug.Print "経度"; lon
End Sub

Function getEUC(CHK_DATA)
    'http://www.ken3.org/asp/backno/asp107.html を使わせていただきました。

    Dim n As Integer
    Dim strWORK As String
    Dim strCODE As String
    Dim P As String
    Dim sEUC As String

    For n = 1 To Len(CHK_DATA)
      strWORK = Mid(CHK_DATA, n, 1)
      strCODE = Hex(Asc(strWORK))
      If Len(strCODE) &lt;= 2 Then
        If strWORK = " " Then
          P = P &amp; "+"
          Else
          P = P &amp; strWORK
        End If
      Else
        sEUC = SJIStoEUC(strCODE)
        P = P &amp; "%" &amp; Mid(sEUC, 1, 2) &amp; "%" &amp; Mid(sEUC, 3, 2)
      End If
    Next

    getEUC = P

End Function

Function SJIStoEUC(strSJISCODE)
    'http://www.ken3.org/asp/backno/asp107.html を使わせていただきました。
    Dim hi
    Dim lo

    'シフトJISコードの上位バイトを hi、下位バイトを lo とします。
    hi = CLng("&amp;h" &amp; Mid(strSJISCODE, 1, 2))
    lo = CLng("&amp;h" &amp; Mid(strSJISCODE, 3, 2))

    If hi &lt;= &amp;H9F Then
      hi = hi - &amp;H71 'hi が 0x9f 以下の場合、 hi から 0x71 減じます。
    Else
      hi = hi - &amp;HB1 'そうでない場合、 hi から 0xB1 減じます。
    End If

    'hi に 2 を乗じて、さらに 1 を加えます。
    hi = hi * 2 + 1

    'lo が 0x7F より大きい場合、 lo から 1 減じます。
    If lo &gt; &amp;H7F Then lo = lo - 1

    'lo が 0x9E 以上の場合、lo から 0x7D 減じて、hi に 1 加えます。
    If lo &gt;= &amp;H9E Then
        lo = lo - &amp;H7D
        hi = hi + 1
    Else 'そうでない場合、 lo から 0x1F 減じます。
        lo = lo - &amp;H1F
    End If

    'JISの hi と lo ができたので、0x80 を or して 最上位のビットを立てます。
    hi = hi Or &amp;H80
    lo = lo Or &amp;H80

    '結果を返します
    SJIStoEUC = Right("0" &amp; Hex(hi), 2) &amp; Right("0" &amp; Hex(lo), 2)

End Function</pre>
<p>getEUC、SJIStoEUCのいずれも、<a href="http://www.ken3.org/asp/backno/asp107.html" target="_blank">http://www.ken3.org/asp/backno/asp107.html</a>を参考に（ほぼ丸写しですが）、作成させていただきました。<br />
とりあえず、「東京都新宿区西新宿二丁目８番１号」を求めるようにしてあります。<br />
実行してみると、</p>
<pre class="showlongcode"><img class="alignnone size-full wp-image-310" title="301-09" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/301-09.jpg" alt="" />　</pre>
<p>　　ん、きちんと変換できてますね（＾＾）</p>
<p>では、最後です。いつものようにA列を全行みて、B,C列に値を入れてみます。</p>
<pre class="showlongcode">]
Sub test()

    Dim lastgyou As Integer
    Dim i As Integer

    Dim lat As String
    Dim lon As String

    Dim nukidashi As String
    Dim eucurlencode As String

    Dim oHttp  As Object
    Set oHttp = CreateObject("MSXML2.XMLHTTP")

    'A列の最終行の行番号を求めます
    lastgyou = ActiveSheet.Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row

    For i = 1 To lastgyou

        'A列の値で検索します
        eucurlencode = getEUC(ActiveSheet.Cells(i, 1).Value)

        oHttp.Open "GET", "http://search.map.yahoo.co.jp/search?q=&amp;p=" + eucurlencode + "&amp;gc=&amp;rsmode=map&amp;ei=euc-jp&amp;type=", False
        oHttp.Send

        '取得した結果をnukidashiに入れます
        nukidashi = oHttp.responseText

        'もし、nukidashiに、「lat=」 と「lot=」が含まれていた場合

        If InStr(nukidashi, "lat=") &lt;&gt; 0 And InStr(nukidashi, "lot=") &lt;&gt; 0 Then

        'とりあえず、nukidashiに、「lat=」以降の文字列を入れます。

        nukidashi = Mid(oHttp.responseText, InStr(oHttp.responseText, "lat=") + 4)

        '次の「&amp;」までがlatです。

        lat = Mid(nukidashi, 1, InStr(nukidashi, "&amp;") - 1)

        'nukidashiを「lon=」以降の文字列にします。

        nukidashi = Mid(nukidashi, InStr(nukidashi, "lon=") + 4)

        '次の「&amp;」までがlonです。

        lon = Mid(nukidashi, 1, InStr(nukidashi, "&amp;") - 1)

        '結果をB列、C列に代入します。

        ActiveSheet.Cells(i, 2).Value = lat
        ActiveSheet.Cells(i, 3).Value = lon

        End If

    Next i

End Sub

Function getEUC(CHK_DATA)
    'http://www.ken3.org/asp/backno/asp107.html を使わせていただきました。

    Dim n As Integer
    Dim strWORK As String
    Dim strCODE As String
    Dim P As String
    Dim sEUC As String

    For n = 1 To Len(CHK_DATA)
      strWORK = Mid(CHK_DATA, n, 1)
      strCODE = Hex(Asc(strWORK))
      If Len(strCODE) &lt;= 2 Then
        If strWORK = " " Then
          P = P &amp; "+"
          Else
          P = P &amp; strWORK
        End If
      Else
        sEUC = SJIStoEUC(strCODE)
        P = P &amp; "%" &amp; Mid(sEUC, 1, 2) &amp; "%" &amp; Mid(sEUC, 3, 2)
      End If
    Next

    getEUC = P

End Function

Function SJIStoEUC(strSJISCODE)
    'http://www.ken3.org/asp/backno/asp107.html を使わせていただきました。
    Dim hi
    Dim lo

    'シフトJISコードの上位バイトを hi、下位バイトを lo とします。
    hi = CLng("&amp;h" &amp; Mid(strSJISCODE, 1, 2))
    lo = CLng("&amp;h" &amp; Mid(strSJISCODE, 3, 2))

    If hi &lt;= &amp;H9F Then
      hi = hi - &amp;H71 'hi が 0x9f 以下の場合、 hi から 0x71 減じます。
    Else
      hi = hi - &amp;HB1 'そうでない場合、 hi から 0xB1 減じます。
    End If

    'hi に 2 を乗じて、さらに 1 を加えます。
    hi = hi * 2 + 1

    'lo が 0x7F より大きい場合、 lo から 1 減じます。
    If lo &gt; &amp;H7F Then lo = lo - 1

    'lo が 0x9E 以上の場合、lo から 0x7D 減じて、hi に 1 加えます。
    If lo &gt;= &amp;H9E Then
        lo = lo - &amp;H7D
        hi = hi + 1
    Else 'そうでない場合、 lo から 0x1F 減じます。
        lo = lo - &amp;H1F
    End If

    'JISの hi と lo ができたので、0x80 を or して 最上位のビットを立てます。
    hi = hi Or &amp;H80
    lo = lo Or &amp;H80

    '結果を返します
    SJIStoEUC = Right("0" &amp; Hex(hi), 2) &amp; Right("0" &amp; Hex(lo), 2)

End Function　</pre>
<p>　<br />
　ループでまわすのはいつもどおりです。A列の値をとって、緯度経度を求め、B列、C列に代入します。<br />
また、検索した結果、「lat=」「lot=」がない場合は無視します。<br />
実行すると、、、<br />
<img class="alignnone size-full wp-image-311" title="301-10" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/301-10.jpg" alt="" width="484" height="172" /></p>
<p>ん、値は入りました（＾＾）<br />
この値を使って、地図を表示させてみると、、、<br />
<a href="http://map.yahoo.co.jp/pl?type=static&amp;lat=35.68627083&amp;lon=139.69494083&amp;sc=1&amp;mode=map&amp;layer=0&amp;pointer=on" target="_blank">http://map.yahoo.co.jp/pl?type=static&amp;lat=35.68627083&amp;lon=139.69494083...</a><br />
<a href="http://map.yahoo.co.jp/pl?type=static&amp;lat=35.60133333&amp;lon=140.12643806&amp;sc=1&amp;mode=map&amp;layer=0&amp;pointer=on" target="_blank">http://map.yahoo.co.jp/pl?type=static&amp;lat=35.60133333&amp;lon=140.12643806...</a><br />
<a href="http://map.yahoo.co.jp/pl?type=static&amp;lat=35.44441889&amp;lon=139.64586389&amp;sc=1&amp;mode=map&amp;layer=0&amp;pointer=on" target="_blank">http://map.yahoo.co.jp/pl?type=static&amp;lat=35.44441889&amp;lon=139.64586389...</a><br />
上３つ、東京都庁、千葉県庁、神奈川県庁の住所から得られたURLです。</p>
<p>ん、とりあえずおっけいかな？</p>
<p>もちろん、これはYahoo!できちんと該当する住所が検索されなければ出ませんし、仮に住所を入れて検索した結果、複数の候補があった場合、最初に出てきたlat= lon=を抜き出しますので、それ以降は無視されます。</p>
<p>とりあえず、こちらにアップしておきます。→<a href="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/vbastudy_23.xls">vbastudy_23</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simple-sys.com/blog/2008/04/06/301/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>VBAのお勉強　メールの取り込み</title>
		<link>http://www.simple-sys.com/blog/2008/04/04/289/</link>
		<comments>http://www.simple-sys.com/blog/2008/04/04/289/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 10:11:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[VBAのお勉強]]></category>

		<guid isPermaLink="false">http://www.simple-sys.com/blog/?p=289</guid>
		<description><![CDATA[

以下の記事を参考に、「注文メールの内容をサーバーから受信しExcelに取り込む仕組みのサンプル」という記事を作成しています。よろしかったらどうぞ（＾＾）
http://q.hatena.ne.jp/120724934 [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>以下の記事を参考に、「<a href="http://www.simple-sys.com/blog/mailtorikomi/" target="_blank">注文メールの内容をサーバーから受信しExcelに取り込む仕組みのサンプル</a>」という記事を作成しています。よろしかったらどうぞ（＾＾）</p>
<p><a href="http://q.hatena.ne.jp/1207249344" target="_blank">http://q.hatena.ne.jp/1207249344</a></p>
<p>この手の「人間の代わりに自動的に処理する」系のプログラムは、好きだなぁ（＾＾；）</p>
<p>まず、このメールがどのような状態なのかがわからないので（テキストファイル？xlsの中に貼り付けてある？）</p>
<p>質問者さんの作られたプログラムを見てみると。。。</p>
<p>Set FR = Range(Selection, Cells(Rows.Count, Selection.Column).End(xlUp)).Find("*[商品]*", , xlValues)</p>
<p>ん、使ったことのない命令ばかり（＾＾；）<br />
<span id="more-289"></span><br />
まず、Findから見ていきます。</p>
<p>「<a href="http://search.yahoo.co.jp/search?fr=slv1-ytpprn&amp;p=VBA%20Excel%20Find" target="_blank">VBA Excel Find</a>」で検索すると。。。<a href="http://www.moug.net/tech/exvba/0050116.htm" target="_blank">こちらのページ</a>が分かりやすかったです。</p>
<p>Rangeオブジェクト（範囲を表すオブジェクト）から、条件に当てはまるセルを探す、というメソッドらしいです。</p>
<p>"*[商品]*" となっていますから、おそらく、「　[商品]　」という値を含むセルを探す、ということでしょうか？</p>
<p>３つめのパラメータは「xlValues」となっていますが、検索の対象を指定しているとの事です。この場合、セルの値で探す、という事ですね。</p>
<p>んじゃ、どの範囲を探すのか？が、前のRange( ) で指定されている、、、どこになるんだろ？（＾＾；）</p>
<p>Rangeってのは、どうやって指定してるのか？「<a href="http://search.yahoo.co.jp/search?fr=slv1-ytpprn&amp;p=VBA%20Excel%20range" target="_blank">VBA Excel range</a>」で検索すると、、<a href="http://www.eurus.dti.ne.jp/~yoneyama/Excel/vba/vba_cell.html" target="_blank">こちらのページ</a>が見つかりました。</p>
<p>Rangeはプロパティで、Range(最初のセル,最後のセル)ってことらしいです。</p>
<p>最初のセル：Selection</p>
<p>最後のセル：Cells(Rows.Count, Selection.Column).End(xlUp)</p>
<p>ってことらしいです。</p>
<p>・・・Selectionってなんだろうか？（＾＾；）　たぶん、今選択しているセルのことだろうけど。。。</p>
<p>「<a href="http://search.yahoo.co.jp/search?fr=slv1-ytpprn&amp;p=VBA%20Excel%20selection" target="_blank">VBA Excel selection</a>」で検索。<a href="http://www.ken3.org/vba/backno/vba109.html" target="_blank">こちらのページ</a>が見つかりました。。。ActiveCellみたいな物らしいですが、</p>
<p>Ｓｅｌｅｃｔｉｏｎの場合は複数のセルを選択しているときは、セルの範囲を返すようです。</p>
<p>うーん、、、よくわからないですが、今選択されているセルから、その列のデータの一番最後の行までを見てるって感じなのかな？</p>
<p>ということで。</p>
<p><a href="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/289-01.jpg"><img class="alignnone size-full wp-image-290" title="289-01" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/289-01.jpg" alt="" width="500" height="619" /></a></p>
<p>こんな感じにシートに貼り付けたメールの文章で、今選択しているセル（上の例では「Ａ1」）から下に、最終行まで見ていくってことにしてみます。</p>
<p>とりあえず、プログラムです。</p>
<pre class="showlongcode">Sub test()
    Dim DB(35)             As Variant
    Dim imamiterugyou      As Integer
    Dim imamiterugyou_atai As String
    Dim fromgyou           As Integer
    Dim lastgyou           As Integer
    Dim shouhinmei_shouhinbangou_color_size As String
    Dim shouhinbangounukidashi As String
    Dim color As String
    Dim size As String
    
    '商品を代入する変数を空にしておきます。
    DB(13) = ""
    DB(14) = ""
    
    
    '今選択しているセルの行を求めます。
    fromgyou = ActiveCell.Row
    
    '今選択しているセルの最終行を求めます。
    lastgyou = ActiveSheet.Cells(ActiveSheet.Rows.Count, ActiveCell.Column).End(xlUp).Row
    
    '今見ている行を設定します。最初は、fromgyouです。
    imamiterugyou = fromgyou
    
    Do
        
        '今見てる行の値をimamiterugyou_ataiに入れます。
        imamiterugyou_atai = ActiveSheet.Cells(imamiterugyou, ActiveCell.Column)
        
        '今見ている行の値の内容によって、処理を分けます。
        If imamiterugyou_atai = "[備考]" Then
            
            'もし、今見てる行が[備考]なら,次の行から
            '[ショップ名]が先頭から始まる行の前までをDB(25)に追加していきます。
            Do
            
                '今見てる行を１行下にします。
                imamiterugyou = imamiterugyou + 1
                
                '今見てる行の値を変数に代入します。
                imamiterugyou_atai = ActiveSheet.Cells(imamiterugyou, ActiveCell.Column)
                
                'もし今見てる行が「　[ショップ名]　」で始まるなら、備考は終わりなのでループから抜けます。
                If InStr(imamiterugyou_atai, "[ショップ名]") = 1 Then Exit Do
                
                'DB(25)に今見てる行の値を追加します。
                DB(25) = DB(25) + imamiterugyou_atai
            
            Loop While imamiterugyou &lt;= lastgyou
        
        ElseIf imamiterugyou_atai = "[配送日時指定]" Then
                    
            'もし、今見てる行が[配送日時指定]なら、DB(22)に値を入れます。
            
            'まず、２行下の時間とスペースを入れます。
            DB(22) = ActiveSheet.Cells(imamiterugyou + 2, ActiveCell.Column) + " "
            '次に、１行下の日付を入れます。
            DB(22) = DB(22) + ActiveSheet.Cells(imamiterugyou + 1, ActiveCell.Column)
        
            '片方しか値が入っていない場合のために、半角スペースをTrimします
            DB(22) = Trim(DB(22))
            
            '今見てる行を３行下にします。
            imamiterugyou = imamiterugyou + 3
        
        ElseIf InStr(imamiterugyou_atai, "[送付先]") = 1 Then
        
            'もし今見てる行の先頭が「　[送付先]　」の場合、
            'まず、「　[送付先]　」の文字列以降を取り出します。
        
            imamiterugyou_atai = Mid(imamiterugyou_atai, 6)
            
            'DB(30)に漢字の姓名を入れます。半角かっこの「 ( 」の１文字前をTrimしたものとします。

            DB(30) = Trim(Mid(imamiterugyou_atai, 1, InStr(imamiterugyou_atai, "(") - 1))
            
            'DB(31)に姓名のフリガナを入れます。半角かっこで囲まれた部分とします。
            DB(31) = Mid(imamiterugyou_atai, InStr(imamiterugyou_atai, "(") + 1, InStr(imamiterugyou_atai, ")") - InStr(imamiterugyou_atai, "(") - 1)
            
            '次の行に郵便番号、住所が入っているとします。
            imamiterugyou = imamiterugyou + 1
            
            '今見てる行の値を変数に代入します。
            imamiterugyou_atai = ActiveSheet.Cells(imamiterugyou, ActiveCell.Column)
        
            '郵便番号は、この行の２文字目から、最初の半角スペースの前までとします。
            DB(32) = Mid(imamiterugyou_atai, 2, InStr(imamiterugyou_atai, " ") - 2)
                    
            '住所は、最初の半角スペースの後ろとします。
            DB(33) = Mid(imamiterugyou_atai, InStr(imamiterugyou_atai, " ") + 1)
        
            '次の行に電話番号が入ってるとします。
            imamiterugyou = imamiterugyou + 1
            
            '今見てる行の値を変数に代入します。
            imamiterugyou_atai = ActiveSheet.Cells(imamiterugyou, ActiveCell.Column)
        
            '電話番号は、この行の７文字目以降とします。
            DB(34) = Mid(imamiterugyou_atai, 7)
        
        ElseIf imamiterugyou_atai = "[商品]" Then
        
            '以下、商品の抜出です。
            '今見てる行を１行下にします。
            imamiterugyou = imamiterugyou + 1
        
        
            Do
                '色とサイズの変数を空にします。
            
                color = ""
                size = ""
                
                '１行目の商品名（商品番号＋カラー＋サイズ）の行をshouhinmei_shouhinbangou_color_sizeに代入します。
                shouhinmei_shouhinbangou_color_size = ActiveSheet.Cells(imamiterugyou, ActiveCell.Column)
            
                '今見てる行を１行下にします。
                imamiterugyou = imamiterugyou + 1
                
                Do
                    '今見てる行の値を変数に代入します。
                    imamiterugyou_atai = ActiveSheet.Cells(imamiterugyou, ActiveCell.Column)
                    
                    'もし、今見ている行が、「 価格 」から始まる行ならば、ループから抜けます
                    If InStr(imamiterugyou_atai, "価格") = 1 Then Exit Do
                
                    'もし、今見てる行が、「カラー:」から始まる行ならば、colorにカラーを入れます。
                    If InStr(imamiterugyou_atai, "カラー:") = 1 Then
                        
                        color = Mid(imamiterugyou_atai, 5)
                    
                    End If
                
                    'もし、今見てる行が、「サイズ:」から始まる行ならば、sizeにサイズを入れます。
                    If InStr(imamiterugyou_atai, "サイズ:") = 1 Then
                        
                        size = Mid(imamiterugyou_atai, 5)
                    
                    End If
                
                    '今見てる行を１行下にします。
                    imamiterugyou = imamiterugyou + 1
                
                Loop While imamiterugyou &lt;= lastgyou
            
                '商品番号を抜き出します。商品番号は、shouhinmei_shouhinbangou_color_sizeのかっこの内側
                'の文字列の後ろについているカラーとサイズを省いた部分です。
                                
                '取りあえず、「(」より後ろの文字を抜き出します。
                shouhinbangounukidashi = Mid(shouhinmei_shouhinbangou_color_size, InStr(shouhinmei_shouhinbangou_color_size, "(") + 1)
                '最後の「)」を除きます。
                shouhinbangounukidashi = Mid(shouhinbangounukidashi, 1, Len(shouhinbangounukidashi) - 1)
            
                'カラーとサイズの文字数文だけ、後ろを削除します。
                shouhinbangounukidashi = Mid(shouhinbangounukidashi, 1, Len(shouhinbangounukidashi) - Len(color + size))
                
                'DB(13)に連結します。
                
                DB(13) = DB(13) + IIf(DB(13) &lt;&gt; "", ",", "") + shouhinbangounukidashi
                
                
                '今見ている価格の行から、個数を抜き出します。
                'まず、「x 」から後ろの文字列を抜き出します。
                imamiterugyou_atai = Mid(imamiterugyou_atai, InStr(imamiterugyou_atai, "x ") + 2)
                
                '次に、「(」より前の文字列を抜き出します。これが個数です。
                imamiterugyou_atai = Mid(imamiterugyou_atai, 1, InStr(imamiterugyou_atai, "(") - 1)
            
                'DB(14)に連結します。
                DB(14) = DB(14) + IIf(DB(14) &lt;&gt; "", ",", "") + shouhinmei_shouhinbangou_color_size + "x " + imamiterugyou_atai
            
                
                Do
                    '今見てる行を１行下にします。
                    imamiterugyou = imamiterugyou + 1
                
                    '今見てる行の値を変数に代入します。
                    imamiterugyou_atai = ActiveSheet.Cells(imamiterugyou, ActiveCell.Column)
            
                    'もし、その行が*********************************************************************だったら、ループから抜けます。
                    If imamiterugyou_atai = "*********************************************************************" Then Exit Do
                    'もし、その行が----------だったら、ループから抜けます。
                    If imamiterugyou_atai = "----------" Then Exit Do
            
            
                Loop While imamiterugyou &lt;= lastgyou
                
                'もし、今見た行が*********************************************************************だったら、ループから抜けます。
                If imamiterugyou_atai = "*********************************************************************" Then Exit Do
            
                '今見てる行を１行下にします。
                imamiterugyou = imamiterugyou + 1
            
            Loop While imamiterugyou &lt;= lastgyou
        
        Else
            
            '今見てる行を１行下にします。
            imamiterugyou = imamiterugyou + 1
        End If
    
    Loop While imamiterugyou &lt;= lastgyou
    
    If DB(13) = "" Then MsgBox "商品が見つかりません", 48: Exit Sub
    If DB(30) = "" Then MsgBox "送付先が見つかりません", 48: Exit Sub
    
    Debug.Print "DB(13)="; DB(13)
    Debug.Print "DB(14)="; DB(14)
    Debug.Print "DB(22)="; DB(22)
    Debug.Print "DB(25)="; DB(25)
    Debug.Print "DB(30)="; DB(30)
    Debug.Print "DB(31)="; DB(31)
    Debug.Print "DB(32)="; DB(32)
    Debug.Print "DB(33)="; DB(33)
    Debug.Print "DB(34)="; DB(34)

End Sub</pre>
<p>（＾＾；）ひたすら長っ・・・<br />
とりあえず、実行結果は、以下のとおり。<br />
<img class="alignnone size-full wp-image-291" title="289-02" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/289-02.jpg" alt="" width="452" height="168" /><br />
ん。いいんでないかい？（＾＾）</p>
<p>ただし、、、これで完成とはいえません。<br />
どのようなメールの文面でも正確に抜き出せるか、というと、今サンプルで出ているメールの文面であれば問題ないですが、</p>
<p>例えば、<br />
・漢字の姓名欄に半角のかっこが入っていた場合（それ以降をフリガナとみなします）<br />
・郵便番号がない場合<br />
・住所や、名前、電話番号が複数行で入っている場合<br />
・備考の内容が　「[ショップ名]」から始まる文字列が入っていた場合（本来の備考として取り込めない行が発生します）<br />
・今出ている行以外に余計な行があった場合（出来るだけ無視するようにしてありますが、、）</p>
<p>など、こちらで想定していない形のデータがきた場合は、うまく抜き出せません。</p>
<p>とりあえず、こちらに置いときます。→<a href="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/vbastudy_22.xls">vbastudy_22</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simple-sys.com/blog/2008/04/04/289/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>ブログを全部消しました（＾＾；）</title>
		<link>http://www.simple-sys.com/blog/2008/04/04/281/</link>
		<comments>http://www.simple-sys.com/blog/2008/04/04/281/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 02:28:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[未分類]]></category>

		<guid isPermaLink="false">http://www.simple-sys.com/blog/?p=281</guid>
		<description><![CDATA[

このブログ、WordPressを使っているんですが。
いろんなプラグインを試しては、外したりして。
アクセス解析に、「ShortStat」を入れたり、「SlimStat」を入れたりしてたんですが。
phpMyAdmi [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p>このブログ、WordPressを使っているんですが。</p>
<p>いろんなプラグインを試しては、外したりして。</p>
<p>アクセス解析に、「ShortStat」を入れたり、「SlimStat」を入れたりしてたんですが。<br />
phpMyAdminで見てみると、今は使ってないプラグインのテーブルがあるなぁ。。<br />
使ってないのは消すか。。。</p>
<p><img class="alignnone size-full wp-image-282" title="281-01" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/281-01.jpg" alt="" width="249" height="88" /></p>
<p>いらなそうなテーブルを選んで。。。</p>
<p><img class="alignnone size-full wp-image-283" title="281-02" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/281-02.jpg" alt="" width="203" height="66" /></p>
<p>削除、と。</p>
<p><img class="alignnone size-full wp-image-284" title="281-03" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/281-03.jpg" alt="" width="284" height="118" /></p>
<p>ん、Ok。</p>
<p>・</p>
<p>・</p>
<p>・<br />
<span id="more-281"></span><br />
（＾＾；）　ＯＫじゃない・・・・・・（＾＾；）</p>
<p>普段、phpMyAdminをほとんど使わないので（たまにテーブルの中身を確認するくらい）、使い方をよく把握していませんでした。</p>
<p>ということで、、、全部消えた・・・・（＾＾；）</p>
<p>やばい（＾＾；）・・・・</p>
<p>ほとんどアクセスもない、貧弱な記事とはいえ、ここんとこいっぱい更新してたので、その時間が全て無になる・・・</p>
<p>頭真っ白（＾＾；）・・・・言葉を失う、とはこの事だ。</p>
<p>もちろん、バックアップなんて取っといてないし（というか、バックアップの仕方も知らないし（＾＾；））</p>
<p>・</p>
<p>・</p>
<p>・</p>
<p>データベースが消えただけなので、Webサーバー上には、使ってたプラグインやテーマのファイル、アップロードした画像などのファイルは残ってましたが。。。肝心の記事が入ったデータがないわけで・・・</p>
<p>１時間くらい、呆然としてました（＾＾；）</p>
<p>なんとか、なんとか復旧できないか。</p>
<p>Yahoo!で検索「<a href="http://search.yahoo.co.jp/search?p=MySQL+drop+database+%E5%BE%A9%E6%97%A7&amp;ei=UTF-8&amp;fr=top_ga1&amp;x=wrt&amp;meta=vc%3D" target="_blank">MySQL drop database 復旧</a>」　出てくるのは業者ばっかり（＾＾；）</p>
<p>はてなで「<a href="http://search.hatena.ne.jp/questsearch?word=mysql+drop" target="_blank">mysql drop</a>」で検索。<a href="http://q.hatena.ne.jp/1092032160" target="_blank">こちらのページ</a>が見つかりましたが、「ファイルシステム復旧」。。。</p>
<p>消えたＭｙＳＱＬのファイルを復旧させれば、何とかなるかも、って感じですね。</p>
<p>「<a href="http://search.yahoo.co.jp/search?p=linux+%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%80%80%E5%89%8A%E9%99%A4+%E5%BE%A9%E6%97%A7&amp;ei=UTF-8&amp;fr=slv1-ytpprn&amp;x=wrt" target="_blank">Linux ファイル削除　復旧</a>」、、、業者か、「復旧するのは難しい」、「バックアップを取っておけ」とかとか。。。</p>
<p>・・・</p>
<p>あきらめるかなぁ、、、金を出してまで復旧させたい内容ではないし、、、ここらへんで「自己満足ブログをやめろ」という神の啓示なのかなぁ、、、</p>
<p>えーい、あきらめきれん（＾＾；）</p>
<p>サーバーに、何かログとか残ってないかな？</p>
<p>「<a href="http://search.yahoo.co.jp/search?fr=slv1-ytpprn&amp;p=mysql%20%a5%ed%a5%b0" target="_blank">mysql ログ</a>」で検索。「バイナリログ」ってのがあるらしい。。。</p>
<p>そういえば、phpMyAdminにも「バイナリログ」とかいう項目があったような。。。</p>
<p><img class="alignnone size-full wp-image-286" title="281-04" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/281-04.jpg" alt="" width="103" height="74" /></p>
<p>開くと、、、</p>
<p><img class="alignnone size-full wp-image-287" title="281-05" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/281-05.jpg" alt="" width="379" height="245" /></p>
<p>おおぉぉ、なんかそれらしいサイズのファイルが！開いてみると。。。</p>
<p><a href="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/281-06.jpg"><img class="alignnone size-full wp-image-288" title="281-06" src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/281-06.jpg" alt="" width="500" height="213" /></a></p>
<p>（＾＾）Wordpressを初めて使ってからのSQL文が残っているようです（＾＾）</p>
<p>ということは、このSQL文をなんとか引っ張り出せれば、記事の内容も復元できるかも。。。</p>
<p>とりあえず、このバイナリログをバックアップしておき、WordPress自体を再インストール。</p>
<p>空のデータベースが出来上がった状態で、記事を復元していきます。</p>
<p>以下、私の行った手順です。これで正常に動作するかどうかは不明ですが、今のところ私の環境では正常に動作しています。</p>
<ol>
<li>タイトルだけの記事を公開します。</li>
<li>phpMyAdminでwp_postsのファイルの中に追加された行のＩＤを、以前投稿したときのＩＤに直します。</li>
<li>バイナリログから拾った、最終更新のUPDATE文を加工して、必要な項目だけをUPDATEします。</li>
<li>ダッシュボードから内容を確認します。</li>
</ol>
<p>バイナリログから拾い出したUPDATE文は、ブラウザに表示されたものをそのままでは使えませんでした（改行が反映できない）。なぜか私の環境では　mysqlbinlog　でバイナリログをダンプしようとするとエラーになってしまうので、サーバー上の mysql コマンドラインで、-teeオプションを使用して、ログをテキストファイルに書き出し、show binlog eventを使って、バイナリログをテキストファイルに書き出しました。</p>
<p>こうして、なんやらかんやらで、ようやく復旧できました。。。（＾＾；）</p>
<p>仕事上のトラブルではなくて、よかった。。。今後の教訓にしたいと思います。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simple-sys.com/blog/2008/04/04/281/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBAのお勉強　残量を計算してロットを割り当てていく</title>
		<link>http://www.simple-sys.com/blog/2008/04/02/233/</link>
		<comments>http://www.simple-sys.com/blog/2008/04/02/233/#comments</comments>
		<pubDate>Wed, 02 Apr 2008 09:36:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[VBAのお勉強]]></category>

		<guid isPermaLink="false">http://www.simple-sys.com/blog/?p=233</guid>
		<description><![CDATA[

http://okwave.jp/qa3915562.html
 
こんなファイルだとします。
 ピンク色のところが変わったら、黄色いところを自動的に集計する。。。こないだやったイベントですね（＾＾）

Privat [...]]]></description>
			<content:encoded><![CDATA[
<!-- ALL ADSENSE ADS DISABLED -->
<p><a href="http://okwave.jp/qa3915562.html" target="_blank">http://okwave.jp/qa3915562.html</a></p>
<pre class="showlongcode"> <img src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/233-01.jpg" alt="233-01.jpg" /></pre>
<p>こんなファイルだとします。</p>
<p> ピンク色のところが変わったら、黄色いところを自動的に集計する。。。こないだやったイベントですね（＾＾）<br />
<span id="more-233"></span></p>
<pre class="showlongcode">Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row = 4 And (Target.Column = 5 Or Target.Column = 7 Or Target.Column = 9 Or Target.Column = 11) Then
        MsgBox ("ピンクのところが変わったよ")
    End If
End Sub</pre>
<p>Targetで、変わったところを判断して、４行目でかつ、（EまたはGまたはIまたはK）が変わったらメッセージ、と。</p>
<p> ピンクのところを変えてみると</p>
<p> <img src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/233-02.jpg" alt="233-02.jpg" /></p>
<p>ん、おっけい。</p>
<p>ピンクが変わったら何をするか？下の集計を行う前に、いったん黄色のところを全部消しましょう。</p>
<p> これもやったばっかり（＾＾）</p>
<pre class="showlongcode">Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row = 4 And (Target.Column = 5 Or Target.Column = 7 Or Target.Column = 9 Or Target.Column = 11) Then
        ActiveSheet.Range("E5:L10").Clear
    End If
End Sub</pre>
<p>範囲を指定して　.Clear　でクリアーです。ピンクの値を変えてみると。。。 <img src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/233-03.jpg" alt="233-03.jpg" /></p>
<p>（＾＾；）値は消えましたが、罫線や背景色も消えちゃいました（＾＾；）</p>
<p>値だけ消したいんだけど、どうすればよいかな。。。</p>
<p>Yahoo!で、「<a href="http://search.yahoo.co.jp/search?p=Excel+%E3%82%BB%E3%83%AB+%E5%80%A4%E3%82%92%E6%B6%88%E5%8E%BB&amp;ei=UTF-8&amp;fr=slv1-ytpprn&amp;x=wrt" target="_blank">Excel セル 値を消去</a>」で検索すると、<a href="http://www.eurus.dti.ne.jp/~yoneyama/Excel/vba/vba_cell_value.html" target="_blank">こちらのページ</a>が見つかりました。</p>
<p> .ClearContentsで消せばいいみたいですね。</p>
<pre class="showlongcode">Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row = 4 And (Target.Column = 5 Or Target.Column = 7 Or Target.Column = 9 Or Target.Column = 11) Then
        ActiveSheet.Range("E5:L10").ClearContents
    End If
End Sub</pre>
<p><img src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/233-04.jpg" alt="233-04.jpg" /></p>
<p> いったん値と罫線、背景色を戻します。 で、ピンクを変えてみます。 <img src="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/233-05.jpg" alt="233-05.jpg" /></p>
<p>ん、おっけい（＾＾） 後は黄色の部分を作っていく、って事で。</p>
<p> ここの考え方、結構複雑なので、とりあえずプログラムです。</p>
<pre class="showlongcode">Private Sub Worksheet_Change(ByVal Target As Range)
     Dim kaime As Integer
     Dim nokori_shikomiryou As Long
     Dim nokori_lotsuuryou As Long
     Dim suuryou As Long
     Dim imamiteru_lotnogyousuu As Integer
     Dim imano_kiironogyousuu As Integer
     'もし、ピンク色のところが変更されたら
     If Target.Row = 4 And (Target.Column = 5 Or Target.Column = 7 Or Target.Column = 9 Or Target.Column = 11) Then
         '黄色のところの値を全部クリアします。
         ActiveSheet.Range("E5:L10").ClearContents
         '表１を3行目（「A1」のロット）から見ていきます。
         imamiteru_lotnogyousuu = 3
         '1回目から見ていきます。
         kaime = 1
         '残りの仕込量を変数に代入
         nokori_shikomiryou = ActiveSheet.Cells(4, (kaime - 1) * 2 + 5)
         'ロットの数量を変数に代入
         nokori_lotsuuryou = ActiveSheet.Cells(imamiteru_lotnogyousuu, 2)
         '黄色の列の最初の値を5にします。
         imano_kiironogyousuu = 5
         Do
             'もし、残りの仕込量が0なら、終了
             If nokori_shikomiryou = 0 Then Exit Do
             'データの表示。ロット名の表示
             ActiveSheet.Cells(imano_kiironogyousuu, (kaime - 1) * 2 + 5).Value = ActiveSheet.Cells(imamiteru_lotnogyousuu, 1)
             'データの表示。数量の表示
             suuryou = IIf(nokori_shikomiryou &gt;= nokori_lotsuuryou, nokori_lotsuuryou, nokori_shikomiryou)
             ActiveSheet.Cells(imano_kiironogyousuu, (kaime - 1) * 2 + 6).Value = suuryou
             '今表示した数量を、それぞれから引く
             nokori_shikomiryou = nokori_shikomiryou - suuryou
             nokori_lotsuuryou = nokori_lotsuuryou - suuryou
             imano_kiironogyousuu = imano_kiironogyousuu + 1
             'もし、仕込量が0なら次へ進む
             If nokori_shikomiryou = 0 Then
                 imano_kiironogyousuu = 5
                 kaime = kaime + 1
                 nokori_shikomiryou = ActiveSheet.Cells(4, (kaime - 1) * 2 + 5)
                 'もし、残りの仕込量が0なら、終了
                 If nokori_shikomiryou = 0 Then Exit Do
             End If
             'もし、ロットの残量がない場合、次のロットへ進む
             If nokori_lotsuuryou = 0 Then
                 imamiteru_lotnogyousuu = imamiteru_lotnogyousuu + 1
                 nokori_lotsuuryou = ActiveSheet.Cells(imamiteru_lotnogyousuu, 2)
                 'もし、ロットの数量が0の場合、もうロットがないので終了
                 If nokori_lotsuuryou = 0 Then
                     MsgBox ("全部のロットを使っても足りませんでした。")
                     Exit Do
                 End If
             End If
         Loop
     End If
End Sub</pre>
<p>（＾＾；）今までで一番難しいかな？</p>
<p>手作業で黄色い部分を作っていく場合と考え方は同じなんですけどね。</p>
<p>終了判断をするところのプログラムがちょっと汚い感じですが。。。</p>
<p>もし、質問があれば、コメント欄でどぞ。ファイルはこちらにおいておきます。→<a title="vbastudy_21.xls" href="http://www.simple-sys.com/blog/wp-content/uploads/2008/04/vbastudy_21.xls">vbastudy_21.xls</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simple-sys.com/blog/2008/04/02/233/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
