<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>kendrick-kamakuraのブログ</title>
<link>https://ameblo.jp/kendrick-kamakura/</link>
<atom:link href="https://rssblog.ameba.jp/kendrick-kamakura/rss20.xml" rel="self" type="application/rss+xml" />
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
<description>ブログの説明を入力します。</description>
<language>ja</language>
<item>
<title>20260701 細かな修正</title>
<description>
<![CDATA[ <p>&nbsp; &nbsp; &nbsp; &nbsp; Do</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim c As Range</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim NextMin As Double</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NextMin = 1E+308</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For Each c In wsList.Range("A1", wsList.Cells(wsList.Rows.Count, "A").End(xlUp))</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If IsNumeric(c.Value) Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If c.Value &gt; MinNum And c.Value &lt; NextMin Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NextMin = c.Value</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Next</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If NextMin &lt;&gt; 1E+308 Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MinNum = NextMin</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MsgBox "該当する値はありません。"</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'MinNumの数値が入っている行を特定する</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RowNum = Application.WorksheetFunction.Match(MinNum, wsList.Range("A:A"), 0)</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If wsList.Cells(RowNum, "C").Value &lt;&gt; "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'C列に文字があるなら</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Main_Text = Main_Text &amp; wsList.Cells(RowNum, "B").Value &amp; vbLf &amp; wsList.Cells(RowNum, "C").Value &amp; vbLf &amp; vbLf</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'C列に文字がないなら</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Main_Text = Main_Text &amp; wsList.Cells(RowNum, "B").Value &amp; vbLf &amp; vbLf</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If MinNum = MaxNum Then Exit Do</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Loop</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp; &nbsp; 'セルコピー</p><p>&nbsp; &nbsp; If Target.Address = "$C$6" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If Range("F6").Value = "○" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1:B1").Copy</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1").Copy</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p>
]]>
</description>
<link>https://ameblo.jp/kendrick-kamakura/entry-12971319119.html</link>
<pubDate>Wed, 01 Jul 2026 00:13:57 +0900</pubDate>
</item>
<item>
<title>細かな修正をしました</title>
<description>
<![CDATA[ <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim c As Range</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim NextMin As Double</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NextMin = 1E+308</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For Each c In wsList.Range("A1", wsList.Cells(wsList.Rows.Count, "A").End(xlUp))</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If IsNumeric(c.Value) Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If c.Value &gt; MinNum And c.Value &lt; NextMin Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NextMin = c.Value</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Next</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If NextMin &lt;&gt; 1E+308 Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MinNum = NextMin</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MsgBox "該当する値はありません。"</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p>
]]>
</description>
<link>https://ameblo.jp/kendrick-kamakura/entry-12971214885.html</link>
<pubDate>Tue, 30 Jun 2026 00:31:08 +0900</pubDate>
</item>
<item>
<title>VBAツール　アップデート内容　2026年6月28日</title>
<description>
<![CDATA[ <p><b>VBA設定</b></p><p>&nbsp;</p><p>・F2.3 追完の頭文あげる</p><p>・1からナンバリング</p><p>・コピーするときにC1をセレクトするようにする</p><p>&nbsp;</p><p>A列をダブルクリックしたときにダブルクリックしたセルに数字を</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p><b>変更１（１度目と２度目での追完のメールの文章を変化）</b></p><p>&nbsp;</p><p>VBA以外の変更点</p><p>・入力シートのB5に書かれていた内容をD2.D3に場合分けして移動</p><p>・元々D2〜E3にあった内容はE2〜F3へ移動</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>VBA変更点</p><p>ー追完メール本文ー</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; 'メール前半部を作成する</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim First_Text As String</p><p>&nbsp; &nbsp; &nbsp; &nbsp; First_Text = <b>wsIn.Range("D" &amp; R).Value</b> &amp; vbLf &amp; _</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsIn.Range("<b>E</b>" &amp; R).Value &amp; wsIn.Range("B6").Value &amp; StrConv(Format(wsIn.Range("C6").Value, "000000"), vbWide) &amp; wsIn.Range("D6").Value &amp; vbLf &amp; _</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsIn.Range("B7").Value &amp; StrConv(Format(wsIn.Range("C" &amp; R).Value, "yyyy年m月d日"), vbWide) &amp; wsIn.Range("B9").Value &amp; vbLf &amp; vbLf</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '③メール末尾を作成</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim End_Text As String</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End_Text = wsIn.Range("<b>F</b>" &amp; R).Value</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p><b>追完資料に番号を付け、任意の順番で並べられるようにする</b></p><p>&nbsp;</p><p><b>・「一覧」シート</b></p><p>&nbsp;</p><p>Option Explicit</p><p>&nbsp;</p><p>'A列をダブルクリックした時に、そのセルに文字が入っていない場合は番号を１つ進め、数字を入力する。文字が入っている場合は、その文字を消す</p><p>Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)</p><p>&nbsp;</p><p>&nbsp; &nbsp; If Target.Column = 1 And Target.Cells.Count = 1 Then</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Trim(Target.Value &amp; "") = "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'セルが空白なら番号を１つ進め、数字を入力</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Target.Value = WorksheetFunction.Max(Columns("A")) + 1</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' 値が入っているなら消す</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Target.ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; ' 編集モードに入らない</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp;</p><p>&nbsp;End Sub</p><p>&nbsp;</p><p>'A列に文字が入ってる場合はその行をオレンジにする、A列に文字が入ってなかったら塗りつぶしをやめる</p><p>Private Sub Worksheet_Change(ByVal Target As Range)</p><p>&nbsp;</p><p>&nbsp; &nbsp; If Target.Column = 1 And Target.Cells.Count = 1 Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Trim(Target.Value) &lt;&gt; "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' A列に値がある場合</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows(Target.Row).Interior.Color = RGB(255, 192, 0)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' A列が空白の場合</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows(Target.Row).Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;</p><p>End Sub</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p><b>・「追完メール本文」シート</b></p><p>&nbsp;</p><p>Option Explicit</p><p>&nbsp;</p><p>'②で使う変数を定義</p><p>Dim wsList As Worksheet</p><p>Dim MinNum As Double</p><p>Dim Main_Text As String</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '②メール本文を作成</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Set wsList = ThisWorkbook.Worksheets("一覧")</p><p>&nbsp; &nbsp; &nbsp; &nbsp; MinNum = 0</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Main_Text = ""</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '「一覧」シートのA列に入力されている値の最大値を探す</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim MaxNum As Double</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; MaxNum = Application.WorksheetFunction.Max(wsList.Range("A:A"))</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '現在のMinNum以上の最小値を探す変数、MinNumの値がMaxNumと同じになるまで､MinNumの右隣にあるコンテンツをメール本文に加え続ける</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim RowNum As Long</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Do</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '現在のMinNum以上の最小値を探す</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MinNum = Application.WorksheetFunction.MinIfs( _</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsList.Range("A:A"), _</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsList.Range("A:A"), "&gt;" &amp; MinNum)</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RowNum = Application.WorksheetFunction.Match(MinNum, wsList.Range("A:A"), 0)</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Main_Text = Main_Text &amp; wsList.Cells(RowNum, "B").Value &amp; vbLf &amp; wsList.Cells(RowNum, "C").Value &amp; vbLf</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If MinNum = MaxNum Then Exit Do</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Loop</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p><b>以下コード全文</b></p><p><b>・「入力」シート</b></p><p>&nbsp;</p><p>Option Explicit</p><p>&nbsp;</p><p>Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)</p><p>&nbsp;</p><p>&nbsp; &nbsp; ' A2.A3セルのみ対象</p><p>&nbsp; &nbsp; If Target.Address = "$A$2" Or Target.Address = "$A$3" Then</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Trim(Target.Value &amp; "") = "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'A2.A3のセルの選択を解除し、行の塗りつぶしを解除する</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A2:A3").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows("2:3").Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' 空白なら0を入力</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Target.Value = 0</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' 値が入っているなら消し、A2.A3のセルをピンクに塗りつぶす</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Target.ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A2:A3").Interior.Color = RGB(255, 199, 206)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; ' 編集モードに入らない</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp;</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;</p><p>End Sub</p><p>&nbsp;</p><p>'A列に文字が入ってる場合はその行をオレンジにする、A列に文字が入ってなかったら塗りつぶしをやめる</p><p>Private Sub Worksheet_Change(ByVal Target As Range)</p><p>&nbsp;</p><p>&nbsp; &nbsp; If Target.Column = 1 And Target.Cells.Count = 1 Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Trim(Target.Value) &lt;&gt; "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' A列に値がある場合</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows(Target.Row).Interior.Color = RGB(255, 192, 0)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' A列が空白の場合</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows(Target.Row).Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;</p><p>End Sub</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p><b>・「一覧」シート</b></p><p>Option Explicit</p><p>&nbsp;</p><p>'A列をダブルクリックした時に、そのセルに文字が入っていない場合は番号を１つ進め、数字を入力する。文字が入っている場合は、その文字を消す</p><p>Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)</p><p>&nbsp;</p><p>&nbsp; &nbsp; If Target.Column = 1 And Target.Cells.Count = 1 Then</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Trim(Target.Value &amp; "") = "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'セルが空白なら番号を１つ進め、数字を入力</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Target.Value = WorksheetFunction.Max(Columns("A")) + 1</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' 値が入っているなら消す</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Target.ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; ' 編集モードに入らない</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp;</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp;End Sub</p><p>&nbsp;</p><p>'A列に文字が入ってる場合はその行をオレンジにする、A列に文字が入ってなかったら塗りつぶしをやめる</p><p>Private Sub Worksheet_Change(ByVal Target As Range)</p><p>&nbsp;</p><p>&nbsp; &nbsp; If Target.Column = 1 And Target.Cells.Count = 1 Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Trim(Target.Value) &lt;&gt; "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' A列に値がある場合</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows(Target.Row).Interior.Color = RGB(255, 192, 0)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' A列が空白の場合</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows(Target.Row).Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;</p><p>End Sub</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p><b>・「追完メール本文」シート</b></p><p>Option Explicit</p><p>&nbsp;</p><p>'②で使う変数を定義</p><p>Dim wsList As Worksheet</p><p>Dim MinNum As Double</p><p>Dim Main_Text As String</p><p>&nbsp;</p><p>Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)</p><p>'■メール文作成</p><p>&nbsp; &nbsp; If Target.Address = "$C$1" Or Target.Address = "$C$3" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '①メール前半部を作成</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '「入力」セルのA列の一番上の文字が入力されているセルの行を変数rとして定義</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim wsIn As Worksheet</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Set wsIn = ThisWorkbook.Worksheets("入力")</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim R As Long</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; For R = 1 To wsIn.Rows.Count</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If wsIn.Cells(R, 1).Value &lt;&gt; "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit For</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Next R</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; 'メール前半部を作成する</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim First_Text As String</p><p>&nbsp; &nbsp; &nbsp; &nbsp; First_Text = wsIn.Range("D" &amp; R).Value &amp; vbLf &amp; _</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsIn.Range("E" &amp; R).Value &amp; wsIn.Range("B6").Value &amp; StrConv(Format(wsIn.Range("C6").Value, "000000"), vbWide) &amp; wsIn.Range("D6").Value &amp; vbLf &amp; _</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsIn.Range("B7").Value &amp; StrConv(Format(wsIn.Range("C" &amp; R).Value, "yyyy年m月d日"), vbWide) &amp; wsIn.Range("B9").Value &amp; vbLf &amp; vbLf</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '②メール本文を作成</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Set wsList = ThisWorkbook.Worksheets("一覧")</p><p>&nbsp; &nbsp; &nbsp; &nbsp; MinNum = 0</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Main_Text = ""</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '「一覧」シートのA列に入力されている値の最大値を探す</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim MaxNum As Double</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; MaxNum = Application.WorksheetFunction.Max(wsList.Range("A:A"))</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '現在のMinNum以上の最小値を探す変数、MinNumの値がMaxNumと同じになるまで､MinNumの右隣にあるコンテンツをメール本文に加え続ける</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim RowNum As Long</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Do</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '現在のMinNum以上の最小値を探す</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MinNum = Application.WorksheetFunction.MinIfs( _</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsList.Range("A:A"), _</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsList.Range("A:A"), "&gt;" &amp; MinNum)</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RowNum = Application.WorksheetFunction.Match(MinNum, wsList.Range("A:A"), 0)</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Main_Text = Main_Text &amp; wsList.Cells(RowNum, "B").Value &amp; vbLf &amp; wsList.Cells(RowNum, "C").Value &amp; vbLf</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If MinNum = MaxNum Then Exit Do</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Loop</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp;</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '③メール末尾を作成</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim End_Text As String</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End_Text = wsIn.Range("F" &amp; R).Value</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; 'C1セルをダブルクリックした時に、オンライン用プレビューを作成</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Target.Address = "$C$1" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1").Value = First_Text &amp; Main_Text &amp; End_Text</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("B1").Value = wsIn.Range("C" &amp; R).Value</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; 'C3セルをダブルクリックした時に、窓追完用プレビューを作成</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Target.Address = "$C$3" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1").Value = Main_Text</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;&nbsp; &nbsp;</p><p>'■印刷＆セルコピー</p><p>&nbsp; &nbsp; 'セルコピー</p><p>&nbsp; &nbsp; If Target.Address = "$C$6" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1:B1").Copy</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; '印刷</p><p>&nbsp; &nbsp; If Target.Address = "$C$8" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'Range("A1").PrintPreview</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'Range("A1").PrintOut</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp;&nbsp; &nbsp;</p><p>'■入力した内容を消去する</p><p>&nbsp; &nbsp; '日付以外の入力内容を消去する</p><p>&nbsp; &nbsp; If Target.Address = "$C$11" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1:A20").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("B1").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Columns("A").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Columns("C").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Cells.Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C6").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Activate</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C6").Select</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; '全ての入力内容を消去する</p><p>&nbsp; &nbsp; If Target.Address = "$C$13" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1:A20").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("B1").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Columns("A").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Columns("C").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Cells.Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C6").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Columns("A").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Rows("2:3").Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("A2:A3").Interior.Color = RGB(255, 199, 206)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C2").Value = "=WORKDAY(TODAY(),IF(MOD(NOW(),1)&lt;=TIME(12,30,0),10,11))"</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C3").Value = "=WORKDAY(TODAY(),IF(MOD(NOW(),1)&lt;=TIME(12,30,0),5,6))"</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Activate</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C6").Select</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;&nbsp; &nbsp;</p><p>End Sub</p><p>&nbsp;</p>
]]>
</description>
<link>https://ameblo.jp/kendrick-kamakura/entry-12971085679.html</link>
<pubDate>Sun, 28 Jun 2026 19:27:37 +0900</pubDate>
</item>
<item>
<title>メールの作成を自動化しよう　その２（Excel・VBA）</title>
<description>
<![CDATA[ <p>前回作成したツールに変更点を追加しました</p><p>&nbsp;</p><p>変更点</p><p>&nbsp;</p><p>その１</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '「一覧」シートのA行に文字が入っている列のコンテンツについて、変数「Main_Text」に加える。</p><p>&nbsp; &nbsp; &nbsp; &nbsp; For i = 1 To LastRow</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If wsList.Cells(i, "A").Value &lt;&gt; "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If wsList.Cells(i, "C").Value &lt;&gt; "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Main_Text = Main_Text &amp; wsList.Cells(i, "B").Value &amp; vbLf &amp; wsList.Cells(i, "C").Value &amp; vbLf &amp; vbLf</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Main_Text = Main_Text &amp; wsList.Cells(i, "B").Value &amp; vbLf &amp; vbLf</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Next i</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>その２（どちらにも（ThisWorkbook.Worksheets("一覧").Columns("C").ClearContents）を追加）</p><p>&nbsp;</p><p>'■入力した内容を消去する</p><p>&nbsp; &nbsp; '日付以外の入力内容を消去する</p><p>&nbsp; &nbsp; If Target.Address = "$C$11" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1:A20").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Columns("A").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Columns("C").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Cells.Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C6").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Activate</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C6").Select</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; '全ての入力内容を消去する</p><p>&nbsp; &nbsp; If Target.Address = "$C$13" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1:A20").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Columns("A").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Columns("C").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Cells.Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C6").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Columns("A").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Rows("2:3").Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("A2:A3").Interior.Color = RGB(255, 199, 206)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C2").Value = "=WORKDAY(TODAY(),IF(MOD(NOW(),1)&lt;=TIME(12,30,0),10,11))"</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C3").Value = "=WORKDAY(TODAY(),IF(MOD(NOW(),1)&lt;=TIME(12,30,0),5,6))"</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Activate</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C6").Select</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>その３</p><p>変更点</p><p>StrConv(Format(wsIn.Range("C6").Value, "000000"), vbWide)</p><p>StrConv(Format(wsIn.Range("C" &amp; R).Value, "yyyy年m月d日"), vbWide)&nbsp;</p><p>&nbsp;</p><p>全文</p><p>&nbsp;&nbsp; &nbsp; 'メール前半部を作成する</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim First_Text As String</p><p>&nbsp; &nbsp; &nbsp; &nbsp; First_Text = wsIn.Range("B5").Value &amp; vbLf &amp; _</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsIn.Range("D" &amp; R).Value &amp; wsIn.Range("B6").Value &amp; StrConv(Format(wsIn.Range("C6").Value, "000000"), vbWide) &amp; wsIn.Range("D6").Value &amp; vbLf &amp; _</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsIn.Range("B7").Value &amp; StrConv(Format(wsIn.Range("C" &amp; R).Value, "yyyy年m月d日"), vbWide) &amp; wsIn.Range("B9").Value &amp; vbLf &amp; vbLf</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>その４</p><p>'■印刷＆セルコピー</p><p>&nbsp; &nbsp; 'セルコピー</p><p>&nbsp; &nbsp; If Target.Address = "$C$6" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1").Copy</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;&nbsp; &nbsp;</p><p>&nbsp; &nbsp; '印刷</p><p>&nbsp; &nbsp; If Target.Address = "$C$8" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'Range("A1").PrintPreview</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'Range("A1").PrintOut</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; End If</p>
]]>
</description>
<link>https://ameblo.jp/kendrick-kamakura/entry-12969905158.html</link>
<pubDate>Wed, 17 Jun 2026 00:32:35 +0900</pubDate>
</item>
<item>
<title>メールの作成を自動化しよう（Excel・VBA）</title>
<description>
<![CDATA[ <p>メールを自動で作成できるようにしましょう。</p><p>（以下をコピー）</p><p>Sheet1</p><p>&nbsp;</p><p>Option Explicit</p><p>&nbsp;</p><p>Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)</p><p>&nbsp;</p><p>&nbsp; &nbsp; ' A2.A3セルのみ対象</p><p>&nbsp; &nbsp; If Target.Address = "$A$2" Or Target.Address = "$A$3" Then</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Trim(Target.Value &amp; "") = "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'A2.A3のセルの選択を解除し、行の塗りつぶしを解除する</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A2:A3").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows("2:3").Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' 空白なら0を入力</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Target.Value = 0</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' 値が入っているなら消し、A2.A3のセルをピンクに塗りつぶす</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Target.ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A2:A3").Interior.Color = RGB(255, 199, 206)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; ' 編集モードに入らない</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp;</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;</p><p>End Sub</p><p>&nbsp;</p><p>'A列に文字が入ってる場合はその行をオレンジにする、A列に文字が入ってなかったら塗りつぶしをやめる</p><p>Private Sub Worksheet_Change(ByVal Target As Range)</p><p>&nbsp;</p><p>&nbsp; &nbsp; If Target.Column = 1 And Target.Cells.Count = 1 Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Trim(Target.Value) &lt;&gt; "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' A列に値がある場合</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows(Target.Row).Interior.Color = RGB(255, 192, 0)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' A列が空白の場合</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows(Target.Row).Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;</p><p>End Sub</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>Sheet2</p><p>&nbsp;</p><p>Option Explicit</p><p>&nbsp;</p><p>'A列をダブルクリックした時に、そのセルに文字が入っていない場合は0を表示させる。文字が入っている場合は、その文字を消す</p><p>Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)</p><p>&nbsp;</p><p>&nbsp; &nbsp; ' A列の1セルのみ対象</p><p>&nbsp; &nbsp; If Target.Column = 1 And Target.Cells.Count = 1 Then</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Trim(Target.Value &amp; "") = "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' 空白なら0を入力</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Target.Value = 0</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' 値が入っているなら消す</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Target.ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; ' 編集モードに入らない</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp;</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;</p><p>End Sub</p><p>&nbsp;</p><p>'A列に文字が入ってる場合はその行をオレンジにする、A列に文字が入ってなかったら塗りつぶしをやめる</p><p>Private Sub Worksheet_Change(ByVal Target As Range)</p><p>&nbsp;</p><p>&nbsp; &nbsp; If Target.Column = 1 And Target.Cells.Count = 1 Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Trim(Target.Value) &lt;&gt; "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' A列に値がある場合</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows(Target.Row).Interior.Color = RGB(255, 192, 0)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Else</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ' A列が空白の場合</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows(Target.Row).Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;</p><p>End Sub</p><p>&nbsp;</p><p>&nbsp;</p><p>Sheet3</p><p>&nbsp;</p><p>Option Explicit</p><p>&nbsp;</p><p>Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)</p><p>'■メール文作成</p><p>&nbsp; &nbsp; If Target.Address = "$C$1" Or Target.Address = "$C$3" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '①メール前半部を作成</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '「入力」セルのA列の一番上の文字が入力されているセルの行を変数rとして定義</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim wsIn As Worksheet</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Set wsIn = ThisWorkbook.Worksheets("入力")</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim R As Long</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; For R = 1 To wsIn.Rows.Count</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If wsIn.Cells(R, 1).Value &lt;&gt; "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit For</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Next R</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; 'メール前半部を作成する</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim First_Text As String</p><p>&nbsp; &nbsp; &nbsp; &nbsp; First_Text = wsIn.Range("B5").Value &amp; vbLf &amp; _</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsIn.Range("D" &amp; R).Value &amp; wsIn.Range("B6").Value &amp; Format(wsIn.Range("C6").Value, "000000") &amp; wsIn.Range("D6").Value &amp; vbLf &amp; _</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wsIn.Range("B7").Value &amp; wsIn.Range("C" &amp; R).Value &amp; wsIn.Range("B9").Value &amp; vbLf &amp; vbLf</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '②メール本文を作成</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '「一覧」シートのA列に文字が入力されている最終セルの行数を取得</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim wsList As Worksheet</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim LastRow As Long</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim i As Long</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim Main_Text As String</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Set wsList = ThisWorkbook.Worksheets("一覧")</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Main_Text = ""</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; 'A列の最終入力行</p><p>&nbsp; &nbsp; &nbsp; &nbsp; LastRow = wsList.Cells(wsList.Rows.Count, "A").End(xlUp).Row</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '「一覧」シートのA行に文字が入っている列のコンテンツについて、変数「Main_Text」に加える。</p><p>&nbsp; &nbsp; &nbsp; &nbsp; For i = 1 To LastRow</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If wsList.Cells(i, "A").Value &lt;&gt; "" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Main_Text = Main_Text &amp; "・" &amp; wsList.Cells(i, "B").Value &amp; vbLf &amp; vbLf</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Next i</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; '③メール末尾を作成</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Dim End_Text As String</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End_Text = wsIn.Range("E" &amp; R).Value</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; 'C1セルをダブルクリックした時に、オンライン用プレビューを作成</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Target.Address = "$C$1" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1").Value = First_Text &amp; Main_Text &amp; End_Text</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; 'C3セルをダブルクリックした時に、窓追完用プレビューを作成</p><p>&nbsp; &nbsp; &nbsp; &nbsp; If Target.Address = "$C$3" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1").Value = Main_Text</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; &nbsp; &nbsp; End If</p><p>&nbsp; &nbsp; End If</p><p>&nbsp; &nbsp;&nbsp;</p><p>'■印刷＆セルコピー</p><p>&nbsp; &nbsp; If Target.Address = "$C$6" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'Range("A1").PrintPreview</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'Range("A1").PrintOut</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1").Copy</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; End If</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp; &nbsp;&nbsp;</p><p>'■入力した内容を消去する</p><p>&nbsp; &nbsp; '日付以外の入力内容を消去する</p><p>&nbsp; &nbsp; If Target.Address = "$C$11" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1:A20").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Columns("A").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Cells.Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C6").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Activate</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C6").Select</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; End If</p><p>&nbsp; &nbsp;&nbsp;</p><p>&nbsp; &nbsp; '全ての入力内容を消去する</p><p>&nbsp; &nbsp; If Target.Address = "$C$13" Then</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Range("A1:A20").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Columns("A").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("一覧").Cells.Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C6").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Columns("A").ClearContents</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Rows("2:3").Interior.Pattern = xlNone</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("A2:A3").Interior.Color = RGB(255, 199, 206)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C2").Value = "=WORKDAY(TODAY(),IF(MOD(NOW(),1)&lt;=TIME(12,30,0),10,11))"</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C3").Value = "=WORKDAY(TODAY(),IF(MOD(NOW(),1)&lt;=TIME(12,30,0),5,6))"</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Activate</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ThisWorkbook.Worksheets("入力").Range("C6").Select</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cancel = True</p><p>&nbsp; &nbsp; End If</p><p>&nbsp; &nbsp;&nbsp;</p><p>End Sub</p>
]]>
</description>
<link>https://ameblo.jp/kendrick-kamakura/entry-12969701349.html</link>
<pubDate>Mon, 15 Jun 2026 00:24:54 +0900</pubDate>
</item>
<item>
<title>Excel・VBAで役に立つ情報を発信していきます。</title>
<description>
<![CDATA[ <p>Excelでダブルクリックしたセルを選択する方法</p><p><br></p><p>↓ここからコピー&amp;ペースト</p><p><br></p><p></p><p></p><p class="p1"><span class="s1">'A列をダブルクリックした時に、そのセルに文字が入っていない場合は0を表示させる。文字が入っている場合は、その文字を消す</span></p><p class="p1"><span class="s1">Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)</span></p><p class="p2"><span class="s1"></span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>' A列の1セルのみ対象</span></p><p class="p1"><span class="s1"><span class="Apple-converted-space">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>If Target.Column = 1 And Target.Cells.Count = 1 Then</span></p><p class="p2"><span class="s1"></span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>If Trim(Target.Value &amp; "") = "" Then</span></p><p class="p1"><span class="s1"><span class="Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>' 空白なら0を入力</span></p><p class="p1"><span class="s1"><span class="Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>Target.Value = 0</span></p><p class="p1"><span class="s1"><span class="Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>Else</span></p><p class="p1"><span class="s1"><span class="Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>' 値が入っているなら消す</span></p><p class="p1"><span class="s1"><span class="Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>Target.ClearContents</span></p><p class="p1"><span class="s1"><span class="Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>End If</span></p><p class="p2"><span class="s1"></span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>' 編集モードに入らない</span></p><p class="p1"><span class="s1"><span class="Apple-converted-space">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>Cancel = True</span></p><p class="p2"><span class="s1"></span><br></p><p class="p1"><span class="s1"><span class="Apple-converted-space">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span></span>End If</span></p><p class="p2"><span class="s1"></span><br></p><p class="p1"><span class="s1">End Sub</span></p><p></p><br><p></p>
]]>
</description>
<link>https://ameblo.jp/kendrick-kamakura/entry-12969139826.html</link>
<pubDate>Tue, 09 Jun 2026 20:45:19 +0900</pubDate>
</item>
</channel>
</rss>
