<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>はじめてのVBA</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/" />
    <link rel="self" type="application/atom+xml" href="http://simoom.jp/vba/atom.xml" />
    <id>tag:simoom.jp,2008-07-26:/vba//2</id>
    <updated>2008-08-20T13:17:16Z</updated>
    <subtitle>VBAコード サンプル集 Excel, Access, Word
コピー＆ペーストで試してみよう</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.13</generator>

<entry>
    <title>Len</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/08/len.html" />
    <id>tag:simoom.jp,2008:/vba//2.32</id>

    <published>2008-08-20T13:16:25Z</published>
    <updated>2008-08-20T13:17:16Z</updated>

    <summary><![CDATA[Sub sample() &nbsp;&nbsp;&nbsp; MsgBox L...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub sample()</p>
<p>&nbsp;&nbsp;&nbsp; MsgBox <strong>Len</strong>("ABC") '文字数<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>Len</strong>("ABCDEFG") '文字数</p>
<p>End Sub<br /></p>]]>
        
    </content>
</entry>

<entry>
    <title>Mid</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/08/mid.html" />
    <id>tag:simoom.jp,2008:/vba//2.31</id>

    <published>2008-08-12T13:34:19Z</published>
    <updated>2008-08-12T13:36:37Z</updated>

    <summary><![CDATA[Sub sample() &nbsp;&nbsp;&nbsp; MsgBox M...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub sample()</p>
<p>&nbsp;&nbsp;&nbsp; MsgBox <strong>Mid</strong>("abcdef", 2, 3) '2文字目から3文字</p>
<p>End Sub<br /></p>]]>
        
    </content>
</entry>

<entry>
    <title>Right, Left</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/08/right-left.html" />
    <id>tag:simoom.jp,2008:/vba//2.30</id>

    <published>2008-08-08T14:36:22Z</published>
    <updated>2008-08-08T14:36:44Z</updated>

    <summary><![CDATA[Sub sample() &nbsp;&nbsp;&nbsp; MsgBox R...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub sample()</p>
<p>&nbsp;&nbsp;&nbsp; MsgBox <strong>Right</strong>("abcdef", 3) '右の3文字<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>Left</strong>("abcdef", 3) '左の3文字</p>
<p>End Sub<br /></p>]]>
        
    </content>
</entry>

<entry>
    <title>Hour, Minute, Second</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/08/hour-minute-second.html" />
    <id>tag:simoom.jp,2008:/vba//2.29</id>

    <published>2008-08-02T05:57:09Z</published>
    <updated>2008-08-02T05:57:38Z</updated>

    <summary><![CDATA[Sub sample() &nbsp;&nbsp;&nbsp; MsgBox H...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub sample()</p>
<p>&nbsp;&nbsp;&nbsp; MsgBox <strong>Hour</strong>(Now) '時<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>Minute</strong>(Now) '分<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>Second</strong>(Now) '秒</p>
<p>End Sub</p>]]>
        
    </content>
</entry>

<entry>
    <title>Year, Month, Day</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/08/year-month-day.html" />
    <id>tag:simoom.jp,2008:/vba//2.28</id>

    <published>2008-08-02T05:56:10Z</published>
    <updated>2008-08-02T05:56:52Z</updated>

    <summary><![CDATA[Sub sample() &nbsp;&nbsp;&nbsp; MsgBox Y...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub sample()</p>
<p>&nbsp;&nbsp;&nbsp; MsgBox <strong>Year</strong>(Now) '年<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>Month</strong>(Now) '月<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>Day</strong>(Now) '日<br /><br />End Sub<br /></p>]]>
        
    </content>
</entry>

<entry>
    <title>MsgBox, vbNewLine</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/07/msgbox-vbnewline.html" />
    <id>tag:simoom.jp,2008:/vba//2.27</id>

    <published>2008-07-29T14:09:56Z</published>
    <updated>2008-07-29T14:14:55Z</updated>

    <summary><![CDATA[Sub sample()&nbsp;&nbsp;&nbsp; 'メッセージの途中...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub sample()<br /><br />&nbsp;&nbsp;&nbsp; 'メッセージの途中で改行する<br />&nbsp;&nbsp;&nbsp; <strong>MsgBox </strong>"１行目のメッセージ" &amp; <strong>vbNewLine </strong>&amp; "２行目のメッセージ"</p>
<p>End Sub</p>]]>
        
    </content>
</entry>

<entry>
    <title>Format</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/07/format.html" />
    <id>tag:simoom.jp,2008:/vba//2.26</id>

    <published>2008-07-29T13:54:37Z</published>
    <updated>2008-07-29T13:58:57Z</updated>

    <summary><![CDATA[Sub sample() &nbsp;&nbsp;&nbsp; MsgBox F...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub sample()</p>
<p>&nbsp;&nbsp;&nbsp; MsgBox <strong>Format</strong>(Now(), "yyyy/mm/dd")<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>Format</strong>(Now(), "hh:nn:ss")<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>Format</strong>(Now(), "yyyy/mm/dd hh:nn:ss")<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>Format</strong>(Now(), "yy年m月d日 h時n分s秒")</p>
<p>End Sub</p>]]>
        
    </content>
</entry>

<entry>
    <title>UCase, LCase</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/07/ucase-lcase.html" />
    <id>tag:simoom.jp,2008:/vba//2.25</id>

    <published>2008-07-27T13:00:29Z</published>
    <updated>2008-08-02T14:11:34Z</updated>

    <summary><![CDATA[Sub test()&nbsp;&nbsp;&nbsp; MsgBox UCas...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub test()<br /><br />&nbsp;&nbsp;&nbsp; MsgBox <strong>UCase</strong>("ABCabc") '大文字に変換する<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>LCase</strong>("ABCabc") '小文字に変換する<br /><br />End Sub</p>]]>
        <![CDATA[<p><br />Upperのcase、Lowerのcaseと覚えましょう！<br />（写植の活字ケースは、大文字ケースと小文字ケースがあるそうですよ）</p>]]>
    </content>
</entry>

<entry>
    <title>StrConv</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/07/strconv.html" />
    <id>tag:simoom.jp,2008:/vba//2.24</id>

    <published>2008-07-26T14:42:09Z</published>
    <updated>2008-07-26T14:42:46Z</updated>

    <summary><![CDATA[Sub test() &nbsp;&nbsp;&nbsp; MsgBox Str...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub test()</p>
<p>&nbsp;&nbsp;&nbsp; MsgBox <strong>StrConv</strong>("ABC123$", vbWide) '全角文字に変換する<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>StrConv</strong>("ＡＢＣ１２３＄", vbNarrow) '半角文字に変換する</p>
<p>End Sub</p>]]>
        
    </content>
</entry>

<entry>
    <title>MsgBox (Level2)</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/07/msgbox2.html" />
    <id>tag:simoom.jp,2008:/vba//2.23</id>

    <published>2008-07-26T14:29:50Z</published>
    <updated>2008-07-26T14:32:59Z</updated>

    <summary><![CDATA[Sub test()&nbsp;&nbsp;&nbsp; 'メッセージを表示する...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[Sub test()<br /><br />&nbsp;&nbsp;&nbsp; 'メッセージを表示する<br />&nbsp;&nbsp;&nbsp; MsgBox "こんにちは" 'メッセージのみ<br />&nbsp;&nbsp;&nbsp; MsgBox "こんばんは",vbInformation 'アイコンも表示する<br />&nbsp;&nbsp;&nbsp; MsgBox "おはようございます",vbInformation,"タイトル" 'タイトルも表示する<br /><br />End Sub]]>
        
    </content>
</entry>

<entry>
    <title>DateAdd</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/07/dateadd.html" />
    <id>tag:simoom.jp,2008:/vba//2.22</id>

    <published>2008-07-26T14:23:29Z</published>
    <updated>2008-07-26T14:34:00Z</updated>

    <summary><![CDATA[Sub test()&nbsp;&nbsp;&nbsp; '指定した時間を足す(...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub test()<br /><br />&nbsp;&nbsp;&nbsp; '指定した時間を足す(または減らす)<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>DateAdd</strong>("s", 1, Now), , "1秒後"<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>DateAdd</strong>("n", 1, Now), , "1分後" '<strong>mではないので注意!<br /></strong>&nbsp;&nbsp;&nbsp; MsgBox <strong>DateAdd</strong>("h", 1, Now), , "1時間後"<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>DateAdd</strong>("d", 1, Now), , "1日後"<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>DateAdd</strong>("m", 1, Now), , "1ヵ月後"<br />&nbsp;&nbsp;&nbsp; MsgBox <strong>DateAdd</strong>("y", 1, Now), , "1年後"</p>
<p>End Sub</p>]]>
        
    </content>
</entry>

<entry>
    <title>Now</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/07/now.html" />
    <id>tag:simoom.jp,2008:/vba//2.21</id>

    <published>2008-07-26T14:22:37Z</published>
    <updated>2008-07-26T14:23:18Z</updated>

    <summary><![CDATA[Sub test() &nbsp;&nbsp;&nbsp; MsgBox Now...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub test()</p>
<p>&nbsp;&nbsp;&nbsp; MsgBox Now() '現在の時刻</p>
<p>End Sub</p>]]>
        
    </content>
</entry>

<entry>
    <title>If ... Then ... ElseIf ... Else ... End If</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/07/if-then-elseif.html" />
    <id>tag:simoom.jp,2008:/vba//2.20</id>

    <published>2008-07-26T06:56:57Z</published>
    <updated>2008-07-26T14:22:10Z</updated>

    <summary><![CDATA[Sub test() &nbsp;&nbsp;&nbsp; Dim i As I...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub test()</p>
<p>&nbsp;&nbsp;&nbsp; Dim i As Integer<br />&nbsp;&nbsp;&nbsp; i = 4 '他の数字も試してみてください<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; <strong>If </strong>i = 3 <strong>Then<br /></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'i=3のとき<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "iは3です"<br />&nbsp;&nbsp;&nbsp; <strong>ElseIf </strong>i = 4 Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'i=4のとき<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "iは4です"<br />&nbsp;&nbsp;&nbsp; <strong>Else<br /></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'i=3ではなく、i=4でもないとき<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "iは3と4以外です"<br />&nbsp;&nbsp;&nbsp; <strong>End If</strong></p>
<p>End Sub&nbsp;</p>]]>
        
    </content>
</entry>

<entry>
    <title>If ... Then ... Else ... End If</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/07/if-then-else.html" />
    <id>tag:simoom.jp,2008:/vba//2.19</id>

    <published>2008-07-26T02:50:08Z</published>
    <updated>2008-07-26T14:18:48Z</updated>

    <summary><![CDATA[Sub test() &nbsp;&nbsp;&nbsp; Dim i As I...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Office共通" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p>Sub test()</p>
<p>&nbsp;&nbsp;&nbsp; Dim i As Integer<br />&nbsp;&nbsp;&nbsp; i = 4<br />&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; <strong>If </strong>i = 3 <strong>Then<br /></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'i=3のとき<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "iは3です"<br />&nbsp;&nbsp;&nbsp; <strong>Else<br /></strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'i=3ではないとき<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "iは3ではありません"<br />&nbsp;&nbsp;&nbsp; <strong>End If</strong></p>
<p>End Sub</p>]]>
        
    </content>
</entry>

<entry>
    <title>Formula (Excel VBA のみ)</title>
    <link rel="alternate" type="text/html" href="http://simoom.jp/vba/2008/07/formula.html" />
    <id>tag:simoom.jp,2008:/vba//2.18</id>

    <published>2008-07-26T02:32:12Z</published>
    <updated>2008-07-26T14:09:05Z</updated>

    <summary><![CDATA['Excel VBA ONLY Sub test()&nbsp;&nbsp;&n...]]></summary>
    <author>
        <name>simoom</name>
        
    </author>
    
        <category term="Excel" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://simoom.jp/vba/">
        <![CDATA[<p><strong>'Excel VBA ONLY</strong></p>
<p>Sub test()<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;'セルの計算式を設定する<br />&nbsp;&nbsp;&nbsp; Sheets("sheet1").Cells(8, 1).<strong>Formula </strong>= "=1+2+3"</p>
<p>End Sub</p>]]>
        
    </content>
</entry>

</feed>

