<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>mrimai0811のブログ</title>
<link>https://ameblo.jp/mrimai0811/</link>
<atom:link href="https://rssblog.ameba.jp/mrimai0811/rss20.xml" rel="self" type="application/rss+xml" />
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
<description>ブログの説明を入力します。</description>
<language>ja</language>
<item>
<title>おぼえがき</title>
<description>
<![CDATA[ <p>覚書</p><p>&nbsp;</p><p>Option Explicit<br><br>Public Sub 飛行作業線表生成()<br><br>&nbsp; &nbsp; Const INPUT_SHEET_NAME As String = "入力データ"<br>&nbsp; &nbsp; Const OUTPUT_SHEET_NAME As String = "出力データ"<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Const DATA_FIRST_ROW As Long = 61<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Const OUT_FIRST_ROW As Long = 26<br>&nbsp; &nbsp; Const OUT_ROW_STEP As Long = 4<br>&nbsp; &nbsp; Const DEFAULT_TEMPLATE_BLOCKS As Long = 6<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Const DAY_START_MIN As Long = 420 &nbsp; ' 07:00<br>&nbsp; &nbsp; Const DAY_END_MIN As Long = 1320 &nbsp; &nbsp;' 22:00<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Dim wsIn As Worksheet<br>&nbsp; &nbsp; Dim wsOut As Worksheet<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Dim dicAircraft As Object<br>&nbsp; &nbsp; Dim dicOutRow As Object<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Dim keys As Variant<br>&nbsp; &nbsp; Dim i As Long<br>&nbsp; &nbsp; Dim r As Long<br>&nbsp; &nbsp; Dim ac As String<br>&nbsp; &nbsp; Dim dataLastRow As Long<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Dim originLeft As Double<br>&nbsp; &nbsp; Dim nextHourLeft As Double<br>&nbsp; &nbsp; Dim minuteWidth As Double<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Dim requiredBlocks As Long<br>&nbsp; &nbsp; Dim existingBlocks As Long<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; On Error GoTo ErrHandler<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Application.ScreenUpdating = False<br>&nbsp; &nbsp; Application.EnableEvents = False<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Set wsIn = ResolveInputSheet(ThisWorkbook, INPUT_SHEET_NAME)<br>&nbsp; &nbsp; Set wsOut = ResolveOutputSheet(ThisWorkbook, OUTPUT_SHEET_NAME)<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If wsIn Is Nothing Then<br>&nbsp; &nbsp; &nbsp; &nbsp; Err.Raise vbObjectError + 1000, , "入力データ用のシートを特定できませんでした。"<br>&nbsp; &nbsp; End If<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If wsOut Is Nothing Then<br>&nbsp; &nbsp; &nbsp; &nbsp; Err.Raise vbObjectError + 1001, , "出力データ用のシートを特定できませんでした。"<br>&nbsp; &nbsp; End If<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; dataLastRow = GetLastInputRow(wsIn, DATA_FIRST_ROW)<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Set dicAircraft = CreateObject("Scripting.Dictionary")<br>&nbsp; &nbsp; Set dicOutRow = CreateObject("Scripting.Dictionary")<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; For r = DATA_FIRST_ROW To dataLastRow<br>&nbsp; &nbsp; &nbsp; &nbsp; If IsValidRecord(wsIn, r) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ac = Trim$(CStr(wsIn.Cells(r, "D").Value))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If ac &lt;&gt; "" Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If Not dicAircraft.Exists(ac) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dicAircraft.Add ac, ac<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; Next r<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If dicAircraft.Count = 0 Then<br>&nbsp; &nbsp; &nbsp; &nbsp; MsgBox "入力データが見つかりませんでした。", vbExclamation<br>&nbsp; &nbsp; &nbsp; &nbsp; GoTo ExitProc<br>&nbsp; &nbsp; End If<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; requiredBlocks = dicAircraft.Count<br>&nbsp; &nbsp; existingBlocks = GetStoredBlockCount(ThisWorkbook, DEFAULT_TEMPLATE_BLOCKS)<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; ClearGeneratedShapes wsOut<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If requiredBlocks &gt; existingBlocks Then<br>&nbsp; &nbsp; &nbsp; &nbsp; EnsureOutputCapacity wsOut, OUT_FIRST_ROW, OUT_ROW_STEP, DEFAULT_TEMPLATE_BLOCKS, existingBlocks, requiredBlocks<br>&nbsp; &nbsp; &nbsp; &nbsp; existingBlocks = requiredBlocks<br>&nbsp; &nbsp; &nbsp; &nbsp; SetStoredBlockCount ThisWorkbook, existingBlocks<br>&nbsp; &nbsp; Else<br>&nbsp; &nbsp; &nbsp; &nbsp; If existingBlocks &lt; DEFAULT_TEMPLATE_BLOCKS Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; existingBlocks = DEFAULT_TEMPLATE_BLOCKS<br>&nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; &nbsp; &nbsp; SetStoredBlockCount ThisWorkbook, existingBlocks<br>&nbsp; &nbsp; End If<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; ClearAircraftLabels wsOut, OUT_FIRST_ROW, OUT_ROW_STEP, existingBlocks<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; keys = dicAircraft.Keys<br>&nbsp; &nbsp; SortVariantArray keys<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; For i = LBound(keys) To UBound(keys)<br>&nbsp; &nbsp; &nbsp; &nbsp; ac = CStr(keys(i))<br>&nbsp; &nbsp; &nbsp; &nbsp; dicOutRow.Add ac, OUT_FIRST_ROW + (i * OUT_ROW_STEP)<br>&nbsp; &nbsp; &nbsp; &nbsp; wsOut.Range("C" &amp; (OUT_FIRST_ROW + (i * OUT_ROW_STEP))).Value = ac<br>&nbsp; &nbsp; Next i<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; originLeft = wsOut.Range("J1").Left<br>&nbsp; &nbsp; nextHourLeft = wsOut.Range("P1").Left<br>&nbsp; &nbsp; minuteWidth = (nextHourLeft - originLeft) / 60#<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; For r = DATA_FIRST_ROW To dataLastRow<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; If IsValidRecord(wsIn, r) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ac = Trim$(CStr(wsIn.Cells(r, "D").Value))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If dicOutRow.Exists(ac) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim sMin As Long<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim eMin As Long<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim eteHour As Double<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim leftPts As Double<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim widthPts As Double<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim outRow As Long<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim topY As Double, topH As Double<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim mainY As Double, mainH As Double<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim noteY As Double, noteH As Double<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim crewText As String<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim missText As String<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim eteText As String<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim noteText As String<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim kindText As String<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim fillColor As Long<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sMin = HHMMToMinutes(wsIn.Cells(r, "H").Value)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eMin = HHMMToMinutes(wsIn.Cells(r, "L").Value)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If sMin &gt;= 0 Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If eMin &lt;= sMin Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eteHour = GetNumericValue(wsIn.Cells(r, "P").Value)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If eteHour &gt; 0 Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eMin = sMin + CLng(eteHour * 60#)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If eMin &gt; sMin Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If sMin &lt; DAY_END_MIN And eMin &gt; DAY_START_MIN Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If sMin &lt; DAY_START_MIN Then sMin = DAY_START_MIN<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If eMin &gt; DAY_END_MIN Then eMin = DAY_END_MIN<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outRow = CLng(dicOutRow(ac))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; leftPts = originLeft + ((sMin - DAY_START_MIN) * minuteWidth) + 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; widthPts = ((eMin - sMin) * minuteWidth) - 2<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If widthPts &lt; 36 Then widthPts = 36<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; topY = wsOut.Rows(outRow).Top + 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; topH = wsOut.Rows(outRow).Height - 2<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainY = wsOut.Rows(outRow + 1).Top + 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainH = wsOut.Rows(outRow + 1).Height - 2<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; noteY = wsOut.Rows(outRow + 2).Top + 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; noteH = wsOut.Rows(outRow + 2).Height + wsOut.Rows(outRow + 3).Height - 2<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; crewText = BuildCrewText(wsIn, r)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; missText = Trim$(CStr(wsIn.Cells(r, "BQ").Text))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eteText = GetEteText(wsIn.Cells(r, "P").Value)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; noteText = BuildRemarksText(wsIn, r, dataLastRow)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kindText = GetKindText(wsIn, r)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fillColor = GetLineColor(kindText)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddFreeTextBox wsOut, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"senpyo_top_" &amp; CStr(r), _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;leftPts, topY, widthPts, topH, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;crewText, 6.5, False, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msoAlignLeft, msoAnchorMiddle<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddMainBox wsOut, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"senpyo_main_" &amp; CStr(r), _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;leftPts, mainY, widthPts, mainH, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;missText &amp; " &nbsp; " &amp; eteText, fillColor<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddFreeTextBox wsOut, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"senpyo_note_" &amp; CStr(r), _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;leftPts, noteY, widthPts, noteH, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;noteText, 6, True, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;msoAlignLeft, msoAnchorTop<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; Next r<br><br>ExitProc:<br>&nbsp; &nbsp; Application.ScreenUpdating = True<br>&nbsp; &nbsp; Application.EnableEvents = True<br>&nbsp; &nbsp; Exit Sub<br><br>ErrHandler:<br>&nbsp; &nbsp; Application.ScreenUpdating = True<br>&nbsp; &nbsp; Application.EnableEvents = True<br>&nbsp; &nbsp; MsgBox "エラー: " &amp; Err.Description, vbCritical<br>End Sub<br><br>Private Function ResolveInputSheet(ByVal wb As Workbook, ByVal preferredName As String) As Worksheet<br>&nbsp; &nbsp; Dim ws As Worksheet<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; On Error Resume Next<br>&nbsp; &nbsp; Set ResolveInputSheet = wb.Worksheets(preferredName)<br>&nbsp; &nbsp; On Error GoTo 0<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If Not ResolveInputSheet Is Nothing Then Exit Function<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; For Each ws In wb.Worksheets<br>&nbsp; &nbsp; &nbsp; &nbsp; If HasInputSignature(ws) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set ResolveInputSheet = ws<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit Function<br>&nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; Next ws<br>End Function<br><br>Private Function ResolveOutputSheet(ByVal wb As Workbook, ByVal preferredName As String) As Worksheet<br>&nbsp; &nbsp; Dim ws As Worksheet<br>&nbsp; &nbsp; Dim nm As String<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; On Error Resume Next<br>&nbsp; &nbsp; Set ResolveOutputSheet = wb.Worksheets(preferredName)<br>&nbsp; &nbsp; On Error GoTo 0<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If Not ResolveOutputSheet Is Nothing Then Exit Function<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; For Each ws In wb.Worksheets<br>&nbsp; &nbsp; &nbsp; &nbsp; nm = Replace(Trim$(ws.Name), " ", "")<br>&nbsp; &nbsp; &nbsp; &nbsp; If UCase$(nm) = "SHEET2" Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set ResolveOutputSheet = ws<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit Function<br>&nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; Next ws<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; For Each ws In wb.Worksheets<br>&nbsp; &nbsp; &nbsp; &nbsp; If HasOutputSignature(ws) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set ResolveOutputSheet = ws<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit Function<br>&nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; Next ws<br>End Function<br><br>Private Function HasInputSignature(ByVal ws As Worksheet) As Boolean<br>&nbsp; &nbsp; Dim score As Long<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; score = 0<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If SheetContainsText(ws, "NO") Then score = score + 1<br>&nbsp; &nbsp; If SheetContainsText(ws, "A/C") Then score = score + 1<br>&nbsp; &nbsp; If SheetContainsText(ws, "ETD") Then score = score + 1<br>&nbsp; &nbsp; If SheetContainsText(ws, "ETA") Then score = score + 1<br>&nbsp; &nbsp; If SheetContainsText(ws, "ETE") Then score = score + 1<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; HasInputSignature = (score &gt;= 4)<br>End Function<br><br>Private Function HasOutputSignature(ByVal ws As Worksheet) As Boolean<br>&nbsp; &nbsp; Dim score As Long<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; score = 0<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If SheetContainsText(ws, "機番") Then score = score + 1<br>&nbsp; &nbsp; If SheetContainsText(ws, "０７００") Or SheetContainsText(ws, "0700") Then score = score + 1<br>&nbsp; &nbsp; If SheetContainsText(ws, "０８００") Or SheetContainsText(ws, "0800") Then score = score + 1<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; HasOutputSignature = (score &gt;= 2)<br>End Function<br><br>Private Function SheetContainsText(ByVal ws As Worksheet, ByVal searchText As String) As Boolean<br>&nbsp; &nbsp; Dim f As Range<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; On Error Resume Next<br>&nbsp; &nbsp; Set f = ws.Cells.Find(What:=searchText, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; After:=ws.Cells(1, 1), _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LookIn:=xlValues, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LookAt:=xlWhole, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SearchOrder:=xlByRows, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SearchDirection:=xlNext, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MatchCase:=False)<br>&nbsp; &nbsp; On Error GoTo 0<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; SheetContainsText = Not f Is Nothing<br>End Function<br><br>Private Function GetLastInputRow(ByVal ws As Worksheet, ByVal minimumRow As Long) As Long<br>&nbsp; &nbsp; Dim cols As Variant<br>&nbsp; &nbsp; Dim i As Long<br>&nbsp; &nbsp; Dim r As Long<br>&nbsp; &nbsp; Dim lastRow As Long<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; cols = Array("B", "D", "H", "L", "P", "BQ", "BY")<br>&nbsp; &nbsp; lastRow = minimumRow<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; For i = LBound(cols) To UBound(cols)<br>&nbsp; &nbsp; &nbsp; &nbsp; r = ws.Cells(ws.Rows.Count, cols(i)).End(xlUp).Row<br>&nbsp; &nbsp; &nbsp; &nbsp; If r &gt; lastRow Then lastRow = r<br>&nbsp; &nbsp; Next i<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If lastRow &lt; minimumRow Then lastRow = minimumRow<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; GetLastInputRow = lastRow<br>End Function<br><br>Private Function IsValidRecord(ByVal ws As Worksheet, ByVal r As Long) As Boolean<br>&nbsp; &nbsp; Dim ac As String<br>&nbsp; &nbsp; Dim etd As Long<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; ac = Trim$(CStr(ws.Cells(r, "D").Value))<br>&nbsp; &nbsp; etd = HHMMToMinutes(ws.Cells(r, "H").Value)<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If ac = "" Then Exit Function<br>&nbsp; &nbsp; If etd &lt; 0 Then Exit Function<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; IsValidRecord = True<br>End Function<br><br>Private Function HHMMToMinutes(ByVal v As Variant) As Long<br>&nbsp; &nbsp; Dim s As String<br>&nbsp; &nbsp; Dim hh As Long<br>&nbsp; &nbsp; Dim mm As Long<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; On Error GoTo ErrHandler<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If IsDate(v) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; HHMMToMinutes = Hour(CDate(v)) * 60 + Minute(CDate(v))<br>&nbsp; &nbsp; &nbsp; &nbsp; Exit Function<br>&nbsp; &nbsp; End If<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; s = Trim$(CStr(v))<br>&nbsp; &nbsp; s = Replace(s, ":", "")<br>&nbsp; &nbsp; s = Replace(s, "：", "")<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If s = "" Then<br>&nbsp; &nbsp; &nbsp; &nbsp; HHMMToMinutes = -1<br>&nbsp; &nbsp; &nbsp; &nbsp; Exit Function<br>&nbsp; &nbsp; End If<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If Not IsNumeric(s) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; HHMMToMinutes = -1<br>&nbsp; &nbsp; &nbsp; &nbsp; Exit Function<br>&nbsp; &nbsp; End If<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; s = Right$("0000" &amp; s, 4)<br>&nbsp; &nbsp; hh = CLng(Left$(s, 2))<br>&nbsp; &nbsp; mm = CLng(Right$(s, 2))<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If hh &lt; 0 Or hh &gt; 23 Or mm &lt; 0 Or mm &gt; 59 Then<br>&nbsp; &nbsp; &nbsp; &nbsp; HHMMToMinutes = -1<br>&nbsp; &nbsp; Else<br>&nbsp; &nbsp; &nbsp; &nbsp; HHMMToMinutes = hh * 60 + mm<br>&nbsp; &nbsp; End If<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Exit Function<br><br>ErrHandler:<br>&nbsp; &nbsp; HHMMToMinutes = -1<br>End Function<br><br>Private Function BuildCrewText(ByVal ws As Worksheet, ByVal r As Long) As String<br>&nbsp; &nbsp; Dim cols As Variant<br>&nbsp; &nbsp; Dim i As Long<br>&nbsp; &nbsp; Dim txt As String<br>&nbsp; &nbsp; Dim buf As String<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; cols = Array("T", "AA", "AH", "AO", "AV", "BC")<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; For i = LBound(cols) To UBound(cols)<br>&nbsp; &nbsp; &nbsp; &nbsp; txt = Trim$(CStr(ws.Cells(r, cols(i)).Text))<br>&nbsp; &nbsp; &nbsp; &nbsp; If txt &lt;&gt; "" Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If buf &lt;&gt; "" Then buf = buf &amp; "　"<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buf = buf &amp; txt<br>&nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; Next i<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; BuildCrewText = buf<br>End Function<br><br>Private Function BuildRemarksText(ByVal ws As Worksheet, ByVal r As Long, ByVal lastRow As Long) As String<br>&nbsp; &nbsp; Dim rr As Long<br>&nbsp; &nbsp; Dim txt As String<br>&nbsp; &nbsp; Dim buf As String<br>&nbsp; &nbsp; Dim endRow As Long<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; endRow = r + 3<br>&nbsp; &nbsp; If endRow &gt; lastRow Then endRow = lastRow<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; For rr = r To endRow<br>&nbsp; &nbsp; &nbsp; &nbsp; txt = Trim$(CStr(ws.Cells(rr, "BY").Text))<br>&nbsp; &nbsp; &nbsp; &nbsp; If txt &lt;&gt; "" Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If buf &lt;&gt; "" Then buf = buf &amp; vbLf<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buf = buf &amp; txt<br>&nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; Next rr<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; BuildRemarksText = buf<br>End Function<br><br>Private Function GetKindText(ByVal ws As Worksheet, ByVal r As Long) As String<br>&nbsp; &nbsp; GetKindText = Trim$(CStr(ws.Cells(r, "B").Text))<br>End Function<br><br>Private Function GetLineColor(ByVal kindText As String) As Long<br>&nbsp; &nbsp; kindText = Trim$(kindText)<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Select Case True<br>&nbsp; &nbsp; &nbsp; &nbsp; Case kindText Like "訓*"<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetLineColor = RGB(0, 112, 192)<br>&nbsp; &nbsp; &nbsp; &nbsp; Case kindText Like "試*"<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetLineColor = RGB(255, 0, 0)<br>&nbsp; &nbsp; &nbsp; &nbsp; Case kindText Like "要*"<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetLineColor = RGB(255, 255, 0)<br>&nbsp; &nbsp; &nbsp; &nbsp; Case UCase$(kindText) = "GND"<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetLineColor = RGB(255, 255, 255)<br>&nbsp; &nbsp; &nbsp; &nbsp; Case Else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetLineColor = RGB(255, 255, 255)<br>&nbsp; &nbsp; End Select<br>End Function<br><br>Private Function GetEteText(ByVal v As Variant) As String<br>&nbsp; &nbsp; If Trim$(CStr(v)) = "" Then<br>&nbsp; &nbsp; &nbsp; &nbsp; GetEteText = ""<br>&nbsp; &nbsp; ElseIf IsNumeric(v) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; GetEteText = Format$(CDbl(v), "0.0")<br>&nbsp; &nbsp; Else<br>&nbsp; &nbsp; &nbsp; &nbsp; GetEteText = Trim$(CStr(v))<br>&nbsp; &nbsp; End If<br>End Function<br><br>Private Function GetNumericValue(ByVal v As Variant) As Double<br>&nbsp; &nbsp; If IsNumeric(v) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; GetNumericValue = CDbl(v)<br>&nbsp; &nbsp; Else<br>&nbsp; &nbsp; &nbsp; &nbsp; GetNumericValue = 0<br>&nbsp; &nbsp; End If<br>End Function<br><br>Private Sub ClearAircraftLabels(ByVal ws As Worksheet, ByVal firstRow As Long, ByVal rowStep As Long, ByVal blockCount As Long)<br>&nbsp; &nbsp; Dim i As Long<br>&nbsp; &nbsp; For i = 0 To blockCount - 1<br>&nbsp; &nbsp; &nbsp; &nbsp; ws.Range("C" &amp; (firstRow + i * rowStep)).Value = ""<br>&nbsp; &nbsp; Next i<br>End Sub<br><br>Private Sub ClearGeneratedShapes(ByVal ws As Worksheet)<br>&nbsp; &nbsp; Dim i As Long<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; For i = ws.Shapes.Count To 1 Step -1<br>&nbsp; &nbsp; &nbsp; &nbsp; If Left$(ws.Shapes(i).Name, 7) = "senpyo_" Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ws.Shapes(i).Delete<br>&nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; Next i<br>End Sub<br><br>Private Sub EnsureOutputCapacity(ByVal ws As Worksheet, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal firstRow As Long, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal rowStep As Long, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal templateBlocks As Long, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal currentBlocks As Long, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal requiredBlocks As Long)<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Dim sourceStartRow As Long<br>&nbsp; &nbsp; Dim destStartRow As Long<br>&nbsp; &nbsp; Dim blockIndex As Long<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If requiredBlocks &lt;= currentBlocks Then Exit Sub<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; sourceStartRow = firstRow + (templateBlocks - 1) * rowStep<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; For blockIndex = currentBlocks To requiredBlocks - 1<br>&nbsp; &nbsp; &nbsp; &nbsp; destStartRow = firstRow + blockIndex * rowStep<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; ws.Rows(sourceStartRow &amp; ":" &amp; sourceStartRow + rowStep - 1).Copy<br>&nbsp; &nbsp; &nbsp; &nbsp; ws.Rows(destStartRow &amp; ":" &amp; destStartRow + rowStep - 1).Insert Shift:=xlDown<br>&nbsp; &nbsp; &nbsp; &nbsp; Application.CutCopyMode = False<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; ws.Range("C" &amp; destStartRow).Value = ""<br>&nbsp; &nbsp; Next blockIndex<br>End Sub<br><br>Private Function GetStoredBlockCount(ByVal wb As Workbook, ByVal defaultCount As Long) As Long<br>&nbsp; &nbsp; Dim nm As Name<br>&nbsp; &nbsp; Dim v As Variant<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; On Error Resume Next<br>&nbsp; &nbsp; Set nm = wb.Names("_SenpyoBlockCount")<br>&nbsp; &nbsp; On Error GoTo 0<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If nm Is Nothing Then<br>&nbsp; &nbsp; &nbsp; &nbsp; GetStoredBlockCount = defaultCount<br>&nbsp; &nbsp; &nbsp; &nbsp; Exit Function<br>&nbsp; &nbsp; End If<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; On Error Resume Next<br>&nbsp; &nbsp; v = Evaluate(nm.RefersTo)<br>&nbsp; &nbsp; On Error GoTo 0<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If IsNumeric(v) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; If CLng(v) &gt;= defaultCount Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetStoredBlockCount = CLng(v)<br>&nbsp; &nbsp; &nbsp; &nbsp; Else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetStoredBlockCount = defaultCount<br>&nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; Else<br>&nbsp; &nbsp; &nbsp; &nbsp; GetStoredBlockCount = defaultCount<br>&nbsp; &nbsp; End If<br>End Function<br><br>Private Sub SetStoredBlockCount(ByVal wb As Workbook, ByVal blockCount As Long)<br>&nbsp; &nbsp; On Error Resume Next<br>&nbsp; &nbsp; wb.Names("_SenpyoBlockCount").Delete<br>&nbsp; &nbsp; On Error GoTo 0<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; wb.Names.Add Name:="_SenpyoBlockCount", RefersTo:="=" &amp; CStr(blockCount)<br>End Sub<br><br>Private Sub AddMainBox(ByVal ws As Worksheet, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal shpName As String, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal leftPts As Double, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal topPts As Double, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal widthPts As Double, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal heightPts As Double, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal textValue As String, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal fillColor As Long)<br><br>&nbsp; &nbsp; Dim shp As Shape<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Set shp = ws.Shapes.AddShape(msoShapeRectangle, leftPts, topPts, widthPts, heightPts)<br>&nbsp; &nbsp; shp.Name = shpName<br>&nbsp; &nbsp; shp.Placement = xlMoveAndSize<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; With shp<br>&nbsp; &nbsp; &nbsp; &nbsp; .Line.Visible = msoTrue<br>&nbsp; &nbsp; &nbsp; &nbsp; .Line.ForeColor.RGB = RGB(0, 0, 0)<br>&nbsp; &nbsp; &nbsp; &nbsp; .Line.Weight = 0.75<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; .Fill.Visible = msoTrue<br>&nbsp; &nbsp; &nbsp; &nbsp; .Fill.ForeColor.RGB = fillColor<br>&nbsp; &nbsp; &nbsp; &nbsp; .Fill.Solid<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; With .TextFrame2<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .TextRange.Text = textValue<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .TextRange.ParagraphFormat.Alignment = msoAlignLeft<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .VerticalAnchor = msoAnchorMiddle<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .MarginLeft = 3<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .MarginRight = 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .MarginTop = 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .MarginBottom = 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .WordWrap = msoTrue<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .AutoSize = msoAutoSizeTextToFitShape<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; With .TextRange.Font<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Size = 11<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Bold = msoTrue<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Fill.ForeColor.RGB = RGB(0, 0, 0)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End With<br>&nbsp; &nbsp; &nbsp; &nbsp; End With<br>&nbsp; &nbsp; End With<br>End Sub<br><br>Private Sub AddFreeTextBox(ByVal ws As Worksheet, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal shpName As String, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal leftPts As Double, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal topPts As Double, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal widthPts As Double, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal heightPts As Double, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal textValue As String, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal fontSize As Double, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal shrinkToFit As Boolean, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal horizontalAlign As MsoParagraphAlignment, _<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ByVal verticalAnchor As MsoVerticalAnchor)<br><br>&nbsp; &nbsp; Dim shp As Shape<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; Set shp = ws.Shapes.AddTextbox(msoTextOrientationHorizontal, leftPts, topPts, widthPts, heightPts)<br>&nbsp; &nbsp; shp.Name = shpName<br>&nbsp; &nbsp; shp.Placement = xlMoveAndSize<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; With shp<br>&nbsp; &nbsp; &nbsp; &nbsp; .Line.Visible = msoFalse<br>&nbsp; &nbsp; &nbsp; &nbsp; .Fill.Visible = msoFalse<br>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; With .TextFrame2<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .TextRange.Text = textValue<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .TextRange.ParagraphFormat.Alignment = horizontalAlign<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .VerticalAnchor = verticalAnchor<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .MarginLeft = 2<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .MarginRight = 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .MarginTop = 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .MarginBottom = 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .WordWrap = msoTrue<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If shrinkToFit Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .AutoSize = msoAutoSizeTextToFitShape<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .AutoSize = msoAutoSizeNone<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; With .TextRange.Font<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Size = fontSize<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Bold = msoFalse<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Fill.ForeColor.RGB = RGB(0, 0, 0)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End With<br>&nbsp; &nbsp; &nbsp; &nbsp; End With<br>&nbsp; &nbsp; End With<br>End Sub<br><br>Private Sub SortVariantArray(ByRef arr As Variant)<br>&nbsp; &nbsp; Dim i As Long<br>&nbsp; &nbsp; Dim j As Long<br>&nbsp; &nbsp; Dim tmp As Variant<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; If IsEmpty(arr) Then Exit Sub<br>&nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; For i = LBound(arr) To UBound(arr) - 1<br>&nbsp; &nbsp; &nbsp; &nbsp; For j = i + 1 To UBound(arr)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If CStr(arr(i)) &gt; CStr(arr(j)) Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmp = arr(i)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; arr(i) = arr(j)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; arr(j) = tmp<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If<br>&nbsp; &nbsp; &nbsp; &nbsp; Next j<br>&nbsp; &nbsp; Next i<br>End Sub</p>
]]>
</description>
<link>https://ameblo.jp/mrimai0811/entry-12961957640.html</link>
<pubDate>Sat, 04 Apr 2026 18:39:05 +0900</pubDate>
</item>
</channel>
</rss>
