<?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>You Look Too Cool &#187; VBA</title>
	<atom:link href="http://stabucky.com/wp/archives/tag/vba/feed" rel="self" type="application/rss+xml" />
	<link>http://stabucky.com/wp</link>
	<description>ゆるくつくる - stabuckyのブログ。</description>
	<lastBuildDate>Thu, 17 May 2012 12:09:09 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>索引項目一括削除</title>
		<link>http://stabucky.com/wp/archives/4035</link>
		<comments>http://stabucky.com/wp/archives/4035#comments</comments>
		<pubDate>Sat, 07 Apr 2012 01:27:32 +0000</pubDate>
		<dc:creator>stabucky</dc:creator>
				<category><![CDATA[Word]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[索引]]></category>

		<guid isPermaLink="false">http://stabucky.com/wp/?p=4035</guid>
		<description><![CDATA[フィールドはWord文書にただの文字列とは違う効果を与えるための仕組みで、日付が自動的に更新される仕組みもこのフィールドが使われています。 Wordの索引は、対象となる文字列に索引項目フィールドを追加して作られます。 索引項目は「蜜柑{ XE &#8220;蜜柑&#8221;\y&#8221;みかん&#8221;}」のように表示されます。 これを一括して削除するためのマクロです。 Sub 索引項目一括削除() &#160; &#160; For Each myfield In ActiveDocument.Fields &#160; &#160; &#160; &#160; If myfield.Type = wdFieldIndexEntry Then &#160; &#160; &#160; &#160; &#160; &#160; myfield.Delete &#160; &#160; &#160; &#160; End If &#160; &#160; Next End Sub]]></description>
		<wfw:commentRss>http://stabucky.com/wp/archives/4035/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>コメント範囲変更</title>
		<link>http://stabucky.com/wp/archives/4028</link>
		<comments>http://stabucky.com/wp/archives/4028#comments</comments>
		<pubDate>Thu, 05 Apr 2012 22:21:33 +0000</pubDate>
		<dc:creator>stabucky</dc:creator>
				<category><![CDATA[Word]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[コメント]]></category>

		<guid isPermaLink="false">http://stabucky.com/wp/?p=4028</guid>
		<description><![CDATA[Word文書には範囲指定した部分に対してコメントを付けることができます。 しかし範囲を変更することができません。 そこでマクロを作ってみました。 使い方 正しい範囲を指定します。 このとき元の範囲と重なる部分が必要です。つまり範囲を広げるか狭めるかのいずれかです。全く別の場所に移動することはできません。 マクロ「コメント範囲変更」を実行します。 元のコメントが削除され、新たに指定した範囲に元のコメント文がセットされます。 VBAコード Sub コメント範囲変更() &#160; &#160; With Selection.Range &#160; &#160; &#160; &#160; rs = .Start &#160; &#160; &#160; &#160; re = .End &#160; &#160; End With &#160; &#160; For Each mycomment In ActiveDocument.Comments &#160; &#160; &#160; &#160; With mycomment &#160; &#160; &#160; &#160; &#160; &#160; ss = .Scope.Start [...]]]></description>
		<wfw:commentRss>http://stabucky.com/wp/archives/4028/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>コメント一覧作成</title>
		<link>http://stabucky.com/wp/archives/4026</link>
		<comments>http://stabucky.com/wp/archives/4026#comments</comments>
		<pubDate>Thu, 05 Apr 2012 22:19:57 +0000</pubDate>
		<dc:creator>stabucky</dc:creator>
				<category><![CDATA[Word]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[コメント]]></category>

		<guid isPermaLink="false">http://stabucky.com/wp/?p=4026</guid>
		<description><![CDATA[Wordのコメントだけを抽出して一覧にするマクロです。 Word文書を開き、マクロ「コメント一覧作成」を実行すると、文書の末尾にコメント一覧を出力します。 Word2007で確認しました。 VBAコード Sub コメント一覧作成() &#160; &#160; With ActiveDocument.Content &#160; &#160; &#160; &#160; .InsertAfter &#34;【コメント一覧】&#34; &#160; &#160; &#160; &#160; .InsertParagraphAfter &#160; &#160; &#160; &#160; For Each mycomment In ActiveDocument.Comments &#160; &#160; &#160; &#160; &#160; &#160; With mycomment &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; i = .Index &#160; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
		<wfw:commentRss>http://stabucky.com/wp/archives/4026/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>手作りのチケットに通し番号を付ける</title>
		<link>http://stabucky.com/wp/archives/3951</link>
		<comments>http://stabucky.com/wp/archives/3951#comments</comments>
		<pubDate>Thu, 08 Mar 2012 14:33:29 +0000</pubDate>
		<dc:creator>stabucky</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://stabucky.com/wp/?p=3951</guid>
		<description><![CDATA[文化祭などでチケットを手作りすることはよくあると思います。 これをExcelで作り、1枚ずつ通し番号を付けたいとします。 A4の紙を使うとして紙1枚からチケット4枚を印刷することにします。 Excel2007で確認しましたが別のバージョンでも動くと思います。 Excelでチケットを作る Excelで1枚分のチケットを作ります。 通し番号をセットするセルを決めます。ここでは「C2」とします。 1枚分の範囲を3回コピーしてA4版に4枚分のチケットを作ります。 2枚目の通し番号のセルに「=C2+1」と入力します。 3枚目の通し番号のセルに「=C2+2」と入力します。 4枚目の通し番号のセルに「=C2+3」と入力します。 マクロを設定する Visual Basic Editorを開き、次のマクロをセットします。 Sub 連続印刷() &#160; &#160; myrow = 2 'セットするセルの行(C2ならば「2」) &#160; &#160; mycol = 3 'セットするセルの列(C2ならば「3」) &#160; &#160; numberfrom = 1 '最初の番号 &#160; &#160; numberto = 1000 '最後の番号 &#160; &#160; numberstep = 4 '1ページあたりの番号 &#160; &#160; For i = numberfrom To numberto [...]]]></description>
		<wfw:commentRss>http://stabucky.com/wp/archives/3951/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>全角文字間のスペースを削除</title>
		<link>http://stabucky.com/wp/archives/3915</link>
		<comments>http://stabucky.com/wp/archives/3915#comments</comments>
		<pubDate>Fri, 24 Feb 2012 22:39:41 +0000</pubDate>
		<dc:creator>stabucky</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://stabucky.com/wp/?p=3915</guid>
		<description><![CDATA[半角英数字では半角スペースが単語を区切るので、ないと困りますが、日本語間の半角スペースは不要である場合があります。 日本語(半角英数字以外)動詞に挟まれた半角スペースだけを削除するExcelのマクロを考えてみました。 Like演算子を使っています。 3文字ずつチェックし、「日本語」「半角スペース」「日本語」と並んでいる場合、「半角スペース」を取り除き、「日本語」「日本語」とします。 「Like &#8220;[!0-9a-zA-Z]&#8220;」とすることで、半角数字と半角英字以外を調べることができます。 Sub 選択範囲の全角文字間のスペースを削除する() &#160; &#160; Const an = &#34;[!0-9a-zA-Z]&#34; &#160; &#160; Dim c As Object &#160; &#160; Dim s, a As String &#160; &#160; Dim i As Long &#160; &#160; For Each c In Selection &#160; &#160; &#160; &#160; v = c.Value &#160; &#160; &#160; &#160; s = &#34;&#34; &#160; [...]]]></description>
		<wfw:commentRss>http://stabucky.com/wp/archives/3915/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>複数ファイルパスワード操作</title>
		<link>http://stabucky.com/wp/archives/3845</link>
		<comments>http://stabucky.com/wp/archives/3845#comments</comments>
		<pubDate>Thu, 02 Feb 2012 09:52:17 +0000</pubDate>
		<dc:creator>stabucky</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[パスワード]]></category>

		<guid isPermaLink="false">http://stabucky.com/wp/?p=3845</guid>
		<description><![CDATA[複数のExcelファイルに同じパスワードがセットされている場合に、それを一括して解除して保存するマクロです。 逆に一括してパスワードをセットすることもできます。 最初にダイアログでパターンを訊かれますので、解除ならば「はい」、セットならば「いいえ」を選択します。 次にダイアログでパスワードをセットします。 最後にファイルが保存されているフォルダを指定します。下位階層には対応していません。 「&#8221;\*.xls&#8221;」の部分を適宜、変更してください。 Excel2007で確認しました。 Sub 複数ファイルパスワード操作() &#160; &#160; Dim myfolder, myfn, myword, pwopen, pwclose &#160; &#160; Dim pattern &#160; &#160; '操作を選択 &#160; &#160; pattern = MsgBox(&#34;パスワード解除ならば「はい」、セットならば「いいえ」&#34;, vbYesNo) &#160; &#160; If pattern = vbCancel Then &#160; &#160; &#160; &#160; Exit Sub &#160; &#160; End If &#160; &#160; 'パスワードをセット &#160; &#160; myword = InputBox(&#34;パスワードを入力。&#34;) [...]]]></description>
		<wfw:commentRss>http://stabucky.com/wp/archives/3845/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>半角を全角に変換するユーザー定義関数</title>
		<link>http://stabucky.com/wp/archives/3839</link>
		<comments>http://stabucky.com/wp/archives/3839#comments</comments>
		<pubDate>Tue, 31 Jan 2012 10:10:53 +0000</pubDate>
		<dc:creator>stabucky</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[変換]]></category>

		<guid isPermaLink="false">http://stabucky.com/wp/?p=3839</guid>
		<description><![CDATA[ExcelのVBAで半角を全角に変換するのはとても簡単です。 「StrConv」を使うといろいろな変換ができます。 引数に「vbWide」を指定すると半角を全角に変換します。 使用例は次の通りです。 Function han2zen(t) &#160; &#160; han2zen = StrConv(t, vbWide) End Function 次は半角カタカナを全角に変換する方法です。 カタカナは全角に変換するが、英数字は半角のままにしたい、というようなケースに使います。 Function han2zen_kana(t) &#160; &#160; Dim u, v As String &#160; &#160; Dim i As Long &#160; &#160; u = StrConv(t, vbWide) &#160; &#160; For i = 1 To Len(u) &#160; &#160; &#160; &#160; If Mid(u, i, 1) Like &#34;[!ァ-ヶー]&#34; [...]]]></description>
		<wfw:commentRss>http://stabucky.com/wp/archives/3839/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBAでワイルドカードを使う</title>
		<link>http://stabucky.com/wp/archives/3836</link>
		<comments>http://stabucky.com/wp/archives/3836#comments</comments>
		<pubDate>Tue, 31 Jan 2012 10:09:43 +0000</pubDate>
		<dc:creator>stabucky</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://stabucky.com/wp/?p=3836</guid>
		<description><![CDATA[VBAでは「Like」を使ってワイルドカード的な使い方ができます。 If myword Like &#34;[a-z]&#34; Then 使い方は次の通りです。 【構文】 文字列 Like パターン 文字列がパターンに合致するとTrueを返します。 【パターン】 文字パターン 引数stringの中の一致する文字 ? 任意の1文字 * 任意の数の文字 # 任意の1文字の数字(0-9) [charlist] 文字リストcharlistに指定した文字の中の任意の1文字 [!charlist] 文字リストcharlistに指定した文字以外の任意の1文字 次にパターンに文字リストを使う場合の例を示します。 半角カタカナ [ｦ-ﾝ] 半角カタカナはコード順で「ｦｧｨｩ&#8230;ﾚﾛﾜﾝ」と並ぶので「[ｦ-ﾝ]」とします。 全角カタカナ [ァ-ヶー] 全角カタカナはコード順で「ァアィイ&#8230;ンヴヵヶ」と並ぶので「[ァ-ヶ]」とします。 ただし長音が含まれないので、これを含めるため「[ァ-ヶー]」とします。 全角ひらがな [ぁ-んー] 全角ひらがなはコード順で「ぁあぃい&#8230;ゐゑをん」と並ぶので「[ぁ-ん]」とします。 ただし長音が含まれないので、これを含めるため「[ぁ-んー]」とします。 半角英小文字 [a-z] 半角英大文字 [A-Z] 半角数字 # 「[0-9]」としてもよいのですが半角数字に関しては上述の通り「#」という記号が用意されています。]]></description>
		<wfw:commentRss>http://stabucky.com/wp/archives/3836/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>段組みをテキストで出力</title>
		<link>http://stabucky.com/wp/archives/3810</link>
		<comments>http://stabucky.com/wp/archives/3810#comments</comments>
		<pubDate>Wed, 25 Jan 2012 09:56:46 +0000</pubDate>
		<dc:creator>stabucky</dc:creator>
				<category><![CDATA[Word]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[段組み]]></category>

		<guid isPermaLink="false">http://stabucky.com/wp/?p=3810</guid>
		<description><![CDATA[段組みを使ったWord文書を段組みの情報を残したままテキストで出力する方法です。 1段の場合は40文字、2段の場合は19文字で改行を挿入します。 段組みの段数は「段落.PageSetup.TextColumns.Count」で取得できます。 またセクション区切りの部分(文字コードが12)はそのまま出力すると表示がおかしくなるので判定して無視します。 関数「cut」は文字列に指定した文字数で改行を挿入します。 Sub 段組みをテキスト出力() &#160; &#160; '段数に応じて改行を追加しテキストファイルに出力する。 &#160; &#160; Const mojisu1 = 40 '段数が1のとき &#160; &#160; Const mojisu2 = 19 '段数が2のとき &#160; &#160; Const myfilename = &#34;d:\test.txt&#34; &#160; &#160; Dim danrakusu, dansu, mojisu, i &#160; &#160; Dim danraku &#160; &#160; Dim mytext &#160; &#160; '各段落の文字列と段数を取得し、段数に応じて改行を追加する。 &#160; &#160; danrakusu = ActiveDocument.Paragraphs.Count &#160; &#160; [...]]]></description>
		<wfw:commentRss>http://stabucky.com/wp/archives/3810/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>複数ファイルシート一括検索</title>
		<link>http://stabucky.com/wp/archives/3606</link>
		<comments>http://stabucky.com/wp/archives/3606#comments</comments>
		<pubDate>Thu, 22 Dec 2011 11:53:31 +0000</pubDate>
		<dc:creator>stabucky</dc:creator>
				<category><![CDATA[Excel]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[検索]]></category>

		<guid isPermaLink="false">http://stabucky.com/wp/?p=3606</guid>
		<description><![CDATA[Windowsにはファイルの内容を検索する機能があります。 しかしExcelを検索する場合、どのファイルにあるかは表示されますが、どのシートにあるかは表示されません。 シートが多いと、そのファイルを開いてから、また検索する必要があります。 そこで、ある文字列について、特定のフォルダにある、すべてのExcelファイルのすべてのシートを検索し、どのシートにあるかを表示するマクロを考えました。 検索結果を表示するだけでなく、該当のセルにハイパーリンクを張るようになっています。 Excel2007で確認しました。 適当なExcelファイルを用意します。 シートの名前を「検索結果」とします。ここに検索結果が表示されます。 下に書かれているコード(3つの部分)を標準モジュールに貼り付けます(3つまとめて)。 マクロ「複数ファイルシート一括検索」を実行します。 検索したい文字列を入力します。 検索したいフォルダを指定します。 検索結果が表示されます。 「$A$1」という表示はセルを表し、リンクが張られています。クリックすると該当のファイルを開きジャンプします。 宣言 Const resultsn = &#34;検索結果&#34; Dim gyo As Long モジュールの先頭に書きます。 メイン Sub 複数ファイルシート一括検索() &#160; &#160; Dim myfolder, myfn, myword &#160; &#160; myword = InputBox(&#34;検索文字列を入力&#34;) &#160; &#160; With Application.FileDialog(msoFileDialogFolderPicker) &#160; &#160; &#160; &#160; .Title = &#34;フォルダを選択&#34; &#160; &#160; &#160; &#160; .AllowMultiSelect = [...]]]></description>
		<wfw:commentRss>http://stabucky.com/wp/archives/3606/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

