<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>強制終了  |  独学エクセル塾</title>
	<atom:link href="https://dokugakuexcel.com/tag/%e5%bc%b7%e5%88%b6%e7%b5%82%e4%ba%86/feed/" rel="self" type="application/rss+xml" />
	<link>https://dokugakuexcel.com</link>
	<description>初心者から中級者までシステム・関数・VBAを伝授します</description>
	<lastBuildDate>Wed, 05 Jul 2023 15:00:53 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://dokugakuexcel.com/wp-content/uploads/2021/06/cropped-cropped-image-66-1-32x32.jpg</url>
	<title>強制終了  |  独学エクセル塾</title>
	<link>https://dokugakuexcel.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">194648711</site>	<item>
		<title>【マクロVBA練習問題20】強制・途中終了・ループ抜け出し！IFとExit Sub・Forを組み合わせる</title>
		<link>https://dokugakuexcel.com/%e3%80%90%e3%83%9e%e3%82%af%e3%83%advba%e7%b7%b4%e7%bf%92%e5%95%8f%e9%a1%8c20%e3%80%91%e5%bc%b7%e5%88%b6%e3%83%bb%e9%80%94%e4%b8%ad%e7%b5%82%e4%ba%86%e3%83%bb%e3%83%ab%e3%83%bc%e3%83%97%e6%8a%9c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2580%2590%25e3%2583%259e%25e3%2582%25af%25e3%2583%25advba%25e7%25b7%25b4%25e7%25bf%2592%25e5%2595%258f%25e9%25a1%258c20%25e3%2580%2591%25e5%25bc%25b7%25e5%2588%25b6%25e3%2583%25bb%25e9%2580%2594%25e4%25b8%25ad%25e7%25b5%2582%25e4%25ba%2586%25e3%2583%25bb%25e3%2583%25ab%25e3%2583%25bc%25e3%2583%2597%25e6%258a%259c</link>
		
		<dc:creator><![CDATA[matsu]]></dc:creator>
		<pubDate>Wed, 05 Jul 2023 15:00:53 +0000</pubDate>
				<category><![CDATA[繰り返し]]></category>
		<category><![CDATA[条件分岐]]></category>
		<category><![CDATA[マクロVBA練習問題]]></category>
		<category><![CDATA[強制終了]]></category>
		<category><![CDATA[練習問題]]></category>
		<category><![CDATA[Exit For]]></category>
		<category><![CDATA[ループ抜け出し]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[Exit sub]]></category>
		<guid isPermaLink="false">https://dokugakuexcel.com/?p=4418</guid>

					<description><![CDATA[目次 練習問題と内容について・練習問題の狙い・練習問題20について練習問題の内容と動作説明問題内容動作説明ヒント・ヒントその1・ヒントその2・ヒントその3解答コード・回答その①・回答その②必要な知識ループ構造ループの抜け [&#8230;]]]></description>
										<content:encoded><![CDATA[
  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">練習問題と内容について</a><ol><li><a href="#toc2" tabindex="0">・練習問題の狙い</a></li><li><a href="#toc3" tabindex="0">・練習問題20について</a></li></ol></li><li><a href="#toc4" tabindex="0">練習問題の内容と動作説明</a><ol><li><a href="#toc5" tabindex="0">問題内容</a></li><li><a href="#toc6" tabindex="0">動作説明</a></li></ol></li><li><a href="#toc7" tabindex="0">ヒント</a><ol><li><a href="#toc8" tabindex="0">・ヒントその1</a></li><li><a href="#toc9" tabindex="0">・ヒントその2</a></li><li><a href="#toc10" tabindex="0">・ヒントその3</a></li></ol></li><li><a href="#toc11" tabindex="0">解答コード</a><ol><li><a href="#toc12" tabindex="0">・回答その①</a></li><li><a href="#toc13" tabindex="0">・回答その②</a></li></ol></li><li><a href="#toc14" tabindex="0">必要な知識</a><ol><li><a href="#toc15" tabindex="0">ループ構造</a></li><li><a href="#toc16" tabindex="0">ループの抜け出し・強制終了</a></li></ol></li><li><a href="#toc17" tabindex="0">まとめ</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">練習問題と内容について</span></h2>
<!-- /wp:post-content -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><span id="toc2">・練習問題の狙い</span></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>このシリーズでは課題を元にマクロVBAを<span class="marker-under-red"><strong>実践することでスキルを身につける</strong></span>ことが出来ます。</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>正直、ソースコード作成については実践あるのみです！</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>答えのコードについては数例挙げますが、「もっといい答えがある」などの意見があれば</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>問い合わせから連絡ください！  </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>こんな問題を作ってほしいなどの意見もお待ちしております！</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph /-->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><span id="toc3">・練習問題20について</span></h3>
<p>こちらはマクロVBAの知識で少し発展した課題になります。</p>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><span class="marker-under"><strong>強制終了・途中終了・ループ抜け出す練習問題</strong></span>となります。</p>
<p>それでは頑張っていきましょう！</p>
<h2 class="wp-block-heading"><span id="toc4">練習問題の内容と動作説明</span></h2>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading"><span id="toc5">問題内容</span></h3>
<p>セル番地<span class="marker-under"><strong>A1からA10まで順番に数値を2倍にしていき、C列に出力する。その数値が100を超えた場合に処理を終了</strong></span>する。</p>
<p><img fetchpriority="high" decoding="async" width="1079" height="374" class="alignnone wp-image-4419 size-full" src="https://dokugakuexcel.com/wp-content/uploads/2023/07/Pasted-37.png" srcset="https://dokugakuexcel.com/wp-content/uploads/2023/07/Pasted-37.png 1079w, https://dokugakuexcel.com/wp-content/uploads/2023/07/Pasted-37-300x104.png 300w, https://dokugakuexcel.com/wp-content/uploads/2023/07/Pasted-37-1024x355.png 1024w, https://dokugakuexcel.com/wp-content/uploads/2023/07/Pasted-37-768x266.png 768w" sizes="(max-width: 1079px) 100vw, 1079px" /></p>
<h3 class="wp-block-heading"><span id="toc6">動作説明</span></h3>
<p>BAを使用して、セル番地A1からA10までの数値を順番に2倍にしてC列に出力します。</p>
<p>処理中、出力した数値が100を超えた場合には処理を終了します。</p>
<h2 class="wp-block-heading"><span id="toc7">ヒント</span></h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><img decoding="async" class="alignnone  wp-image-4222" src="https://dokugakuexcel.com/wp-content/uploads/2023/06/25232784_m-300x200.jpg" alt="" width="458" height="305" srcset="https://dokugakuexcel.com/wp-content/uploads/2023/06/25232784_m-300x200.jpg 300w, https://dokugakuexcel.com/wp-content/uploads/2023/06/25232784_m-1024x683.jpg 1024w, https://dokugakuexcel.com/wp-content/uploads/2023/06/25232784_m-768x512.jpg 768w, https://dokugakuexcel.com/wp-content/uploads/2023/06/25232784_m-1536x1024.jpg 1536w, https://dokugakuexcel.com/wp-content/uploads/2023/06/25232784_m.jpg 1920w" sizes="(max-width: 458px) 100vw, 458px" /> <br />以下のヒントを参考にして解答コードを作成してみてください。</p>
<h3><span id="toc8">・ヒントその1</span></h3>
<p>ループ構造を使用して、セルの範囲を順番に処理します。</p>
<p>ループ変数を使用して、セルの行番号や列番号を更新していく方法を考えてみましょう。</p>
<h3><span id="toc9">・ヒントその2</span></h3>
<p>条件を満たすと繰り返し処理抜け出す必要があります。</p>
<p><span class="marker-under"><strong>例えば「For Next」で繰り返し処理をしている場合は、「Exit For」でループを抜け出します</strong></span>。</p>
<h3><span id="toc10">・ヒントその3</span></h3>
<p>条件を満たすと強制終了する必要があります。</p>
<p>こちらはとてもシンプルで<span class="marker-under"><strong>「Exit Sub」で強制終了</strong></span>ができます。</p>
<p>以上のヒントを参考に課題に取り組んでみてください！</p>
<p>&nbsp;</p>
<div class="blank-box bb-tab bb-good bb-red">最新・便利な機能を搭載したExcel・officeを試しませんか？ <br />Excel 2013以下を使用している方はサポートが終了しているので注意が必要です！<br /><a href="https://dokugakuexcel.com/excel%e3%83%bboffice%e3%81%ae%e4%be%a1%e6%a0%bc%e6%af%94%e8%bc%83%ef%bc%81%e3%81%82%e3%81%aa%e3%81%9f%e3%81%ab%e5%90%88%e3%81%a3%e3%81%9f%e3%82%aa%e3%82%b9%e3%82%b9%e3%83%a1%e3%81%ae%e8%a3%bd%e5%93%81/">【最新2023年】Excel・Officeの価格比較！あなたに合ったオススメの製品の選定方法から購入 ► 独学エクセル塾 (dokugakuexcel.com)</a></div>
<div> </div>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>&nbsp;</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading"><span id="toc11">解答コード</span></h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>では回答を見ていきましょう！</p>
<p><img decoding="async" class="alignnone  wp-image-4274" src="https://dokugakuexcel.com/wp-content/uploads/2023/06/23623728-300x225.jpg" alt="" width="399" height="299" srcset="https://dokugakuexcel.com/wp-content/uploads/2023/06/23623728-300x225.jpg 300w, https://dokugakuexcel.com/wp-content/uploads/2023/06/23623728-1024x768.jpg 1024w, https://dokugakuexcel.com/wp-content/uploads/2023/06/23623728-768x576.jpg 768w, https://dokugakuexcel.com/wp-content/uploads/2023/06/23623728-1536x1152.jpg 1536w, https://dokugakuexcel.com/wp-content/uploads/2023/06/23623728.jpg 1600w" sizes="(max-width: 399px) 100vw, 399px" /></p>
<h3><span id="toc12">・回答その①</span></h3>
<div class="blank-box bb-tab bb-check bb-blue">
<p>Sub Exercise20to1()<br />Dim row As Integer<br />Dim value As Double<br /><br />For row = 1 To 10<br />　value = Cells(row, 1).value * 2<br />　Cells(row, 3).value = value<br />　　If value &gt; 100 Then<br />　　　<span style="color: #3366ff;"><strong>Exit For</strong></span><br />　　End If<br />Next row<br />End Sub</p>
</div>
<div class="st-yellow">
<p>上記のコードもセル番地A1からA10までの数値を順番に2倍にし、C列に出力するものです。</p>
<p>処理中、出力した数値が100を超えた場合には処理を終了します。</p>
</div>
<div class="st-yellow blank-box sticky">
<p><span class="marker-red" style="font-size: 24px;"><strong>解答コードのポイント</strong></span></p>
<p>1. rowというループ変数を使用して、行番号を順番に更新します。<br />2. value変数にセルの値を2倍にした結果を代入します。<br />3. Range(&#8220;A&#8221; &amp; row).Valueのようにセル番地を文字列と結合して指定します。<br />4. Range(&#8220;B&#8221; &amp; row).Value = valueのようにB列に結果を出力します。<br />5. If value &gt; 100 Then <span style="color: #3366ff;"><strong>Exit For</strong></span>によって、<span class="marker-under"><strong>数値が100を超えた場合にループを終了</strong></span>します。</p>
</div>
<div class="st-yellow">
<p>それでは実行してみましょう。<br />結果はこのようになります。</p>
<p><img decoding="async" width="443" height="312" class="alignnone wp-image-4420 size-full" src="https://dokugakuexcel.com/wp-content/uploads/2023/07/Pasted-38.png" srcset="https://dokugakuexcel.com/wp-content/uploads/2023/07/Pasted-38.png 443w, https://dokugakuexcel.com/wp-content/uploads/2023/07/Pasted-38-300x211.png 300w" sizes="(max-width: 443px) 100vw, 443px" /></p>
<p><span class="marker-under"><strong>A6で100を超えたので、ループを抜け出すことが出来ました。</strong></span><br /><br /></p>
</div>
<h3><span id="toc13">・回答その②</span></h3>
<div class="blank-box bb-tab bb-check bb-blue">
<p>Sub Exercise20to2()<br />Dim row As Integer<br />Dim value As Double<br /><br />For row = 1 To 10<br />　value = Cells(row, 1).value * 2<br />　Cells(row, 3).value = value<br />　　If value &gt; 100 Then<br />　　　<span style="color: #ff0000;"><strong>Exit Sub</strong></span><br />　　End If<br />Next row<br />End Sub</p>
</div>
<div>
<p>先ほどは条件を満たすと、ループを抜け出す方法でしたが、今回は<span class="marker-under"><strong>「強制終了」で処理</strong></span>しています。</p>
</div>
<p>条件を満たすと<span class="marker-under"><strong>「<span style="color: #3366ff;">Exit Sub</span>」で強制終了</strong></span>する仕組みです。</p>
<p>&nbsp;</p>
<p>  <img decoding="async" id="thepasted-1" class="alignnone  wp-image-4221" src="https://dokugakuexcel.com/wp-content/uploads/2023/06/23195909-300x225.png" alt="" width="436" height="327" srcset="https://dokugakuexcel.com/wp-content/uploads/2023/06/23195909-300x225.png 300w, https://dokugakuexcel.com/wp-content/uploads/2023/06/23195909-1024x768.png 1024w, https://dokugakuexcel.com/wp-content/uploads/2023/06/23195909-768x576.png 768w, https://dokugakuexcel.com/wp-content/uploads/2023/06/23195909-1536x1152.png 1536w, https://dokugakuexcel.com/wp-content/uploads/2023/06/23195909.png 1600w" sizes="(max-width: 436px) 100vw, 436px" /></p>
<h2 class="wp-block-heading"><span id="toc14">必要な知識</span></h2>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>この問題を解くためには、以下の基本的な知識が必要です。</p>
<h3><span id="toc15">ループ構造</span></h3>
<p>繰り返し処理をするために、セル範囲内の各セルを順番に読み取るループ構造が必要です。 <br />For Nextループを使った反復処理を利用した反復処理について理解しておくと良いでしょう。</p>
<div class="information-box common-icon-box"><a href="https://dokugakuexcel.com/%e3%80%90vba%e7%9f%a5%e8%ad%98-7%e3%80%91fornext%e3%81%a7%e6%8c%87%e5%ae%9a%e3%81%97%e3%81%9f%e6%95%b0%e5%80%a4%e3%81%a7%e7%b9%b0%e3%82%8a%e8%bf%94%e3%81%97%e3%83%bb%e3%83%ab%e3%83%bc/">【マクロVBA】For…Nextで指定した数値で繰り返し・ループをする方法と途中で抜け出す方法 ► 独学エクセル塾 (dokugakuexcel.com)</a></div>
<p>これらの知識を応用して、問題を解くためのコードを作成しましょう。  </p>
<h3><span id="toc16">ループの抜け出し・強制終了</span></h3>
<p> VBAでは、ループ処理をよく使用しますが、途中でループ処理を中断したい場合があると思います。<br />その際は「<strong><span style="color: #3366ff;">Exit For</span></strong>」を使用してループ処理を抜け出します。</p>
<p>さらに強制終了では「<span style="color: #3366ff;"><strong>Exit Sub</strong></span>」を使用することで直ちに処理を終了することが出来ます。</p>
<p>場面によって使い分けてください。</p>
<div class="blank-box sticky st-yellow"><span style="color: #ff0000;"><strong>ループ抜け出し</strong></span>：<strong><span style="color: #3366ff;">Exit For</span></strong><br /><span style="color: #ff0000;"><strong>強制終了</strong></span>：<span style="color: #3366ff;"><strong>Exit Sub</strong></span></div>
<h2 class="wp-block-heading"><span id="toc17">まとめ</span></h2>
<p>この練習問題では、Excel VBAの基本的な概念と構文に触れながら、セルの操作やループ処理、条件分岐の活用方法を学ぶことができます。</p>
<p>具体的には、セル番地を指定して値を読み取ったり書き込んだりする方法、<br />ループ構造を使ってセル範囲を順番に処理する方法、条件分岐を使用して特定の条件に基づいて処理を終了する方法などが含まれています。</p>
<p>これらの基本的な知識と技術を身につけることで、VBAを使用してExcelの操作を自動化する能力を向上させることができます。<br />また、問題の難易度を徐々に上げることで、より高度なVBAのスキルを磨くことができます。</p>
<p>練習問題を通じて、VBAの基礎を学びながら自身のスキルを向上させていきましょう。<br />練習問題は段階的に難しくなっていくので、自分のペースで取り組むことをおすすめします。</p>
<p>以上が練習問題20となります。お疲れ様でした！</p>]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4418</post-id>	</item>
		<item>
		<title>【マクロVBA】実行中のコードを強制停止・終了する方法！キーボードのみで操作可能</title>
		<link>https://dokugakuexcel.com/%e3%80%90%e3%83%9e%e3%82%af%e3%83%advba%e3%80%91%e5%ae%9f%e8%a1%8c%e4%b8%ad%e3%81%ae%e3%82%b3%e3%83%bc%e3%83%89%e3%82%92%e5%bc%b7%e5%88%b6%e5%81%9c%e6%ad%a2%e3%83%bb%e7%b5%82%e4%ba%86%e3%81%99/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2580%2590%25e3%2583%259e%25e3%2582%25af%25e3%2583%25advba%25e3%2580%2591%25e5%25ae%259f%25e8%25a1%258c%25e4%25b8%25ad%25e3%2581%25ae%25e3%2582%25b3%25e3%2583%25bc%25e3%2583%2589%25e3%2582%2592%25e5%25bc%25b7%25e5%2588%25b6%25e5%2581%259c%25e6%25ad%25a2%25e3%2583%25bb%25e7%25b5%2582%25e4%25ba%2586%25e3%2581%2599</link>
					<comments>https://dokugakuexcel.com/%e3%80%90%e3%83%9e%e3%82%af%e3%83%advba%e3%80%91%e5%ae%9f%e8%a1%8c%e4%b8%ad%e3%81%ae%e3%82%b3%e3%83%bc%e3%83%89%e3%82%92%e5%bc%b7%e5%88%b6%e5%81%9c%e6%ad%a2%e3%83%bb%e7%b5%82%e4%ba%86%e3%81%99/?noamp=mobile#respond</comments>
		
		<dc:creator><![CDATA[matsu]]></dc:creator>
		<pubDate>Fri, 30 Dec 2022 13:55:43 +0000</pubDate>
				<category><![CDATA[便利技]]></category>
		<category><![CDATA[エラー対策]]></category>
		<category><![CDATA[停止]]></category>
		<category><![CDATA[コードの実行]]></category>
		<category><![CDATA[中断]]></category>
		<category><![CDATA[強制終了]]></category>
		<category><![CDATA[Esc]]></category>
		<category><![CDATA[エスケープ]]></category>
		<guid isPermaLink="false">https://dokugakuexcel.com/?p=3970</guid>

					<description><![CDATA[マクロVBAを使用する上で誤って別のプロシージャを実行したり処理時間が長くてコードの実行を途中で止めたい場面があると思います。 その際に通常のメニューにある実行の停止はグレーアウトして選択できないため、プログラム実行が終 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>マクロVBAを使用する上で誤って別のプロシージャを実行したり<br>処理時間が長くて<strong><span class="marker-under">コードの実行を途中で止めたい場面</span></strong>があると思います。</p>



<p>その際に通常のメニューにある実行の停止はグレーアウトして<br>選択できないため、プログラム実行が終わるまで待つ方もいるのではないでしょうか。</p>



<p>そこで今回は<strong><span class="marker-under">キーボード操作のみでできる実行中のコードを<br>停止させる方法</span></strong>について紹介します。</p>



<p>作業自体もとても簡単なので是非参考にしてみてください。<br>それでは見ていきましょう。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-4" checked><label class="toc-title" for="toc-checkbox-4">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">&#x2b1b;︎こんなことができるようになる！</a></li><li><a href="#toc2" tabindex="0">&#x2b1b;︎実行コードを強制停止・終了する</a></li><li><a href="#toc3" tabindex="0">&#x2b1b;︎停止後の復帰方法</a><ol><li><a href="#toc4" tabindex="0">・完全に実行を中断したい場合</a></li><li><a href="#toc5" tabindex="0">・どこまでのコードを実行したか確認して終了する</a></li><li><a href="#toc6" tabindex="0">・コード実行を再開したい場合</a></li></ol></li><li><a href="#toc7" tabindex="0">■Escでも強制終了できない場合</a></li><li><a href="#toc8" tabindex="0">&#x2b1b;︎まとめ</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">&#x2b1b;︎こんなことができるようになる！</span></h2>



<p>・実行中のプロシージャを強制的に途中停止できる。<br>・処理中のコードを途中停止できる</p>



<h2 class="wp-block-heading"><span id="toc2">&#x2b1b;︎実行コードを強制停止・終了する</span></h2>



<p>では本題に入っていきましょう。<br>見本で下記のような簡単なコードを用意しました。</p>



<pre class="wp-block-verse">Sub 繰り返し処理()
Dim Time1 As Double, Time2 As Double, Result As Double
Dim Cycle As Long

Time1 = Timer
For Cycle = 1 To 1000 Step 1
 Cells(1, 1) = "=SUM(D:D)"
 Cells(1, 1) = "=SUM(D:D)" 
 Cells(1, 1) = "=SUM(D:D)"
Next Cycle

Time2 = Timer
Result = Time2 - Time1
MsgBox Result &amp; "秒で処理しました"
End Sub
</pre>



<p>内容としてはセル番地A1からA3にＤ列の合計の算出を<br>SUM関数を用いて<strong><span class="marker-under-red">10000回繰り返すコード</span></strong>になります。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="519" height="153" src="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-88.png" alt="" class="wp-image-3971" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-88.png 519w, https://dokugakuexcel.com/wp-content/uploads/2022/12/image-88-300x88.png 300w" sizes="(max-width: 519px) 100vw, 519px" /></figure>



<p>見本なので無意味な繰り返しをしていますが<br>こちらを<strong><span class="marker-under">実行すると「138秒」かかってしまいます</span></strong>。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-89.png" alt="" class="wp-image-3972" width="202" height="153"/></figure>



<p>一度<strong><span class="marker-under-blue">実行してしまうと止まるまでに約２分待たないといけない</span></strong>ので<br>誤動作時にはとてもめんどくさいです。<br>こちらを<strong><span class="marker-under">実行中に途中で止めてみましょう</span></strong>。</p>



<p>使用するキーは<strong><span class="marker-under">「エスケープキー」</span></strong>になります。<br>大半のキーボードでは左上に配置されており<strong><span class="marker-under">「Esc」</span></strong>と記されていると思います。</p>



<p>では実際に「Escキー」を活用してみましょう。<br>活用方法は簡単で、<strong><span class="marker-under-red">実行中に押すのみです</span></strong>。</p>



<p>では先程のコードを実行して「Escキー」を押してみたいと思います。<br>結果はこのようになりました。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-90.png" alt="" class="wp-image-3973" width="454" height="217" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-90.png 611w, https://dokugakuexcel.com/wp-content/uploads/2022/12/image-90-300x143.png 300w" sizes="(max-width: 454px) 100vw, 454px" /></figure>



<p>「コードの実行が中断されました。」というメッセージが表示されました。<br>よく、エラー時に表示されるメッセージです。</p>



<p>では確認も含めてデバッグを押してみましょう。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="528" height="211" src="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-91.png" alt="" class="wp-image-3974" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-91.png 528w, https://dokugakuexcel.com/wp-content/uploads/2022/12/image-91-300x120.png 300w" sizes="(max-width: 528px) 100vw, 528px" /></figure>



<p>変数Nは本来であれば<strong><span class="marker-under-red">10000回繰り返しますが<br>543回で止まっています</span></strong>。</p>



<p>つまり<strong><span class="marker-under">強制的に停止が出来たことになります。</span></strong></p>



<p>とても簡単ですね。</p>



<h2 class="wp-block-heading"><span id="toc3">&#x2b1b;︎停止後の復帰方法</span></h2>



<p>ここからは<strong><span class="marker-under">停止の復帰方法</span></strong>です。<br>デバッグ作業をされた事がある方は復習になりますが<br>一連の復帰方法を見ていきましょう。</p>



<h3 class="wp-block-heading"><span id="toc4">・完全に実行を中断したい場合</span></h3>



<p>現在の状態はあくまで強制停止状態にあります。<br>なので、そこから再度実行もできますし、デバッグもできます。</p>



<p>今回は<strong><span class="marker-under-red">完全に実行を中断</span></strong>するわけですから<br>先程のメッセージから<strong><span class="marker-under-red">「終了」</span></strong>を押します。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="611" height="291" src="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-92.png" alt="" class="wp-image-3975" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-92.png 611w, https://dokugakuexcel.com/wp-content/uploads/2022/12/image-92-300x143.png 300w" sizes="(max-width: 611px) 100vw, 611px" /></figure>



<p>これで強制終了が終わりました。</p>



<p>注意点として、<strong><span class="marker-under">どこまでのコードが実行されたかは<br>確認が出来ないのでシートを確認して現状を把握する必要があります。</span></strong></p>



<p>どこまでのコードが実行されたか確認する方法は次の項目で説明します。</p>



<h3 class="wp-block-heading"><span id="toc5">・どこまでのコードを実行したか確認して終了する</span></h3>



<p>今度はどこまでのコードが実行されたか確認して終了する手順を紹介します。</p>



<p>「Escキー」を押した後にでるメニューか<strong><span class="marker-under-red">「デバッグ」</span></strong>を選択します。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="611" height="291" src="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-93.png" alt="" class="wp-image-3976" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-93.png 611w, https://dokugakuexcel.com/wp-content/uploads/2022/12/image-93-300x143.png 300w" sizes="(max-width: 611px) 100vw, 611px" /></figure>



<p>すると<strong><span class="marker-under">黄色く塗りつぶされた行があるのですか<br>そこまでコードが実行されたことを示します。</span></strong></p>



<figure class="wp-block-image size-full"><img decoding="async" width="604" height="211" src="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-94.png" alt="" class="wp-image-3977" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-94.png 604w, https://dokugakuexcel.com/wp-content/uploads/2022/12/image-94-300x105.png 300w" sizes="(max-width: 604px) 100vw, 604px" /></figure>



<p>見本のように繰り返し動作の場合は変数を確認すれば何回まで繰り返し処理が行われたか確認することが出来ます。</p>



<p>その後、「<strong><span class="marker-under">リセット」ボタンにて停止中のプロシージャを<br>完全に中断</span></strong>することができます。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-95.png" alt="" class="wp-image-3978" width="631" height="154" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-95.png 631w, https://dokugakuexcel.com/wp-content/uploads/2022/12/image-95-300x73.png 300w" sizes="(max-width: 631px) 100vw, 631px" /></figure>



<p></p>



<h3 class="wp-block-heading"><span id="toc6">・コード実行を再開したい場合</span></h3>



<p>最後に<strong><span class="marker-under">コードの実行を再開したい場合</span></strong>を見ていきましょう。</p>



<p>まずは、アラーム時の復帰から見ていきます。</p>



<p></p>



<p>操作は簡単でメニューにある<strong><span class="marker-under-red">「継続」</span></strong>を押せば、動作を再開してくれます。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-96.png" alt="" class="wp-image-3979" width="508" height="241" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-96.png 615w, https://dokugakuexcel.com/wp-content/uploads/2022/12/image-96-300x142.png 300w" sizes="(max-width: 508px) 100vw, 508px" /></figure>



<p></p>



<p>次に<strong><span class="marker-under">「デバッグ」で停止させた後に再開の方法</span></strong>を見ていきましょう。</p>



<p>こちらは<strong><span class="marker-under-red">「F5」</span></strong>キーまたは<strong><span class="marker-under-red">「ユーザーフォームの実行」ボタン</span></strong>でコード実行の再開を行うことができます。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-97.png" alt="" class="wp-image-3980" width="433" height="145" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-97.png 609w, https://dokugakuexcel.com/wp-content/uploads/2022/12/image-97-300x100.png 300w" sizes="(max-width: 433px) 100vw, 433px" /></figure>



<p>もちろん再開後も再度、「Esc」キーで停止させることも可能です。</p>



<h2 class="wp-block-heading"><span id="toc7">■Escでも強制終了できない場合</span></h2>



<p>Escキーでも止まらない場合は<strong><span class="marker-under">タスクマネージャーで停止させる</span></strong>ことも可能です。</p>



<p>しかし、先ほどまでの停止方法とは異なり、Excel自体の強制終了になるので</p>



<p><strong><span class="marker-under-red">上書き保存をしていないと、前回の保存以降の処理が消えてしまうので注意が必要</span></strong>です。</p>



<p></p>



<p>では方法を見ていきましょう。</p>



<p></p>



<p>まずキーボードの<strong><span class="marker-under-blue">「Ctrl」+「Alt」+「Delete」</span></strong>を押します。</p>



<p>するとメニューが表示されるので「<strong><span class="marker-under-blue">タスクマネージャー</span></strong>」を選択します。</p>



<p></p>



<p>「<strong><span class="marker-under-blue">プロセス」タブ</span></strong>に<strong><span class="marker-under-blue">「Microsoft　Excel」</span></strong>の項目があると思うので<strong><span class="marker-under-blue">選択</span></strong>します。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-98.png" alt="" class="wp-image-3984" width="552" height="286" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/12/image-98.png 829w, https://dokugakuexcel.com/wp-content/uploads/2022/12/image-98-300x156.png 300w, https://dokugakuexcel.com/wp-content/uploads/2022/12/image-98-768x398.png 768w" sizes="(max-width: 552px) 100vw, 552px" /></figure>



<p>最後に<strong><span class="marker-under-blue">「タスクの終了」</span></strong>があるのでこちらを選択します。</p>



<p>するとExcelが強制終了します。</p>



<p></p>



<p>強制終了後のファイルの復元方法については下記記事をご参照ください☟</p>



<p><a href="https://dokugakuexcel.com/%e4%bf%9d%e5%ad%98%e3%81%a7%e3%81%8d%e3%81%9a%e3%81%ab%e7%b5%82%e4%ba%86%e3%83%bb%e4%b8%8a%e6%9b%b8%e3%81%8d%e3%81%97%e3%81%9f%e3%82%a8%e3%82%af%e3%82%bb%e3%83%ab%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab/">保存できずに終了・上書きしたエクセルファイルを復元する方法一覧！消えたファイルを元に戻す ► 独学エクセル塾 (dokugakuexcel.com)</a></p>



<p></p>



<p>いずれも<strong><span class="marker-under-red">コードの実行前には上書きを推奨</span></strong>します。</p>



<h2 class="wp-block-heading"><span id="toc8">&#x2b1b;︎まとめ</span></h2>



<p>いかがだったでしょうか。<br>処理に時間がかかるプロシージャを途中で止めたくなった<br>場合など様々な場面で使用できそうですね。</p>



<p>また「Escキー」のみで操作可能なので<br>とても簡単な方法になっています。</p>



<p>是非参考にしてみてください。<br>それでは次回の記事でお会いしましょう。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://dokugakuexcel.com/%e3%80%90%e3%83%9e%e3%82%af%e3%83%advba%e3%80%91%e5%ae%9f%e8%a1%8c%e4%b8%ad%e3%81%ae%e3%82%b3%e3%83%bc%e3%83%89%e3%82%92%e5%bc%b7%e5%88%b6%e5%81%9c%e6%ad%a2%e3%83%bb%e7%b5%82%e4%ba%86%e3%81%99/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3970</post-id>	</item>
	</channel>
</rss>
