<?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/%E3%83%96%E3%83%AC%E3%83%BC%E3%82%AF%E3%83%9D%E3%82%A4%E3%83%B3%E3%83%88/feed/" rel="self" type="application/rss+xml" />
	<link>https://dokugakuexcel.com</link>
	<description>初心者から中級者までシステム・関数・VBAを伝授します</description>
	<lastBuildDate>Mon, 17 Oct 2022 12:44:22 +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>【マクロ】指定した位置まで実行する!ブレークポイント・カーソル行の前まで実行の設定と解除方法</title>
		<link>https://dokugakuexcel.com/%e3%80%90%e3%83%9e%e3%82%af%e3%83%advba%e7%9f%a5%e8%ad%98-28%e3%80%91%e6%8c%87%e5%ae%9a%e3%81%97%e3%81%9f%e4%bd%8d%e7%bd%ae%e3%81%be%e3%81%a7%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b%e3%83%96%e3%83%ac/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e3%2580%2590%25e3%2583%259e%25e3%2582%25af%25e3%2583%25advba%25e7%259f%25a5%25e8%25ad%2598-28%25e3%2580%2591%25e6%258c%2587%25e5%25ae%259a%25e3%2581%2597%25e3%2581%259f%25e4%25bd%258d%25e7%25bd%25ae%25e3%2581%25be%25e3%2581%25a7%25e5%25ae%259f%25e8%25a1%258c%25e3%2581%2599%25e3%2582%258b%25e3%2583%2596%25e3%2583%25ac</link>
					<comments>https://dokugakuexcel.com/%e3%80%90%e3%83%9e%e3%82%af%e3%83%advba%e7%9f%a5%e8%ad%98-28%e3%80%91%e6%8c%87%e5%ae%9a%e3%81%97%e3%81%9f%e4%bd%8d%e7%bd%ae%e3%81%be%e3%81%a7%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b%e3%83%96%e3%83%ac/?noamp=mobile#respond</comments>
		
		<dc:creator><![CDATA[matsu]]></dc:creator>
		<pubDate>Mon, 07 Mar 2022 13:04:55 +0000</pubDate>
				<category><![CDATA[デバッグ操作]]></category>
		<category><![CDATA[マクロVBA]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[マクロ]]></category>
		<category><![CDATA[デバッグ]]></category>
		<category><![CDATA[ブレークポイント]]></category>
		<category><![CDATA[カーソル行の前まで実行]]></category>
		<guid isPermaLink="false">https://dokugakuexcel.com/?p=2352</guid>

					<description><![CDATA[マクロVBAのプログラムの実行については他の記事で説明しました。プログラムの実行についての記事はこちらから☟ 【マクロVBA知識 27】ステップイン・オバー・アウトで動作確認（デバッグ）を行う ► 独学エクセル塾 (do [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>マクロVBAのプログラムの実行については他の記事で説明しました。<br>プログラムの実行についての記事はこちらから☟</p>



<p><a href="https://dokugakuexcel.com/%e3%80%90%e3%83%9e%e3%82%af%e3%83%advba%e7%9f%a5%e8%ad%98-27%e3%80%91%e3%82%b9%e3%83%86%e3%83%83%e3%83%97%e3%82%a4%e3%83%b3%e3%83%bb%e3%82%aa%e3%83%90%e3%83%bc%e3%83%bb%e3%82%a2%e3%82%a6%e3%83%88/?preview_id=2337&amp;preview_nonce=03ad05f935&amp;preview=true&amp;_thumbnail_id=2350">【マクロVBA知識 27】ステップイン・オバー・アウトで動作確認（デバッグ）を行う ► 独学エクセル塾 (dokugakuexcel.com)</a></p>



<p>動作確認を行う際にはF8を使用して1行ずつ実行する方法もありますが<br>プログラムが長くなれば手間がかかる上、確認が済んでいるプログラムも1行ずつ確認しないといけません。</p>



<p>そこで今回は<strong><span class="marker-under">指定した位置までプログラムを実行する方法</span></strong>について紹介したいと思います。<br>今回の記事を身に着ければプログラムの動作確認が楽になりますので是非参考にしてみてください。</p>



<p>それでは見ていきましょう。</p>




  <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></li><li><a href="#toc2" tabindex="0">■カーソル行の前まで実行する方法について</a></li><li><a href="#toc3" tabindex="0">■ブレークポイントを活用する</a></li><li><a href="#toc4" tabindex="0">&#x2b1b;︎公式の説明</a></li><li><a href="#toc5" tabindex="0">■まとめ</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">■見本のプログラムを紹介</span></h2>



<p>まず、機能をプログラムを用いて説明するため見本のプログラムを準備しました。<br>内容は下図の見本を作成してみました。</p>



<figure class="wp-block-image size-full is-resized"><img fetchpriority="high" decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-28.png" alt="" class="wp-image-2353" width="389" height="350" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-28.png 483w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-28-300x270.png 300w" sizes="(max-width: 389px) 100vw, 389px" /></figure>



<p>行いたい作業として、単価と購入数が入力されてある場合に<br>E列の総額を計算するプログラムを作成したいと思います。</p>



<p>作成したプログラムは下記の通りです。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Sub 総額の計算()</p><p>Dim Cycle As Variant</p><p>For Cycle = 4 To 16 Step 1</p><p>If Cells(Cycle, 3) &lt;&gt; &#8220;&#8221; Then<br>Cells(Cycle, 5) = Cells(Cycle, 3) * Cells(Cycle, 4)<br>End If</p><p>Next Cycle</p><p>End Sub</p></blockquote>



<p>今回は実行についての記事なので詳しくは説明しませんが、<br>「For Next」 と「If」を使用した簡単なプログラムです。</p>



<p>「For Next」 と「If」の記事はこちらから☟</p>



<p><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/?preview_id=453&amp;preview_nonce=21fd6b56f7&amp;preview=true&amp;_thumbnail_id=457">【VBA知識 7】FOR…NEXTで指定した数値で繰り返し・ループ動作をする。 ► 独学エクセル塾 (dokugakuexcel.com)</a></p>



<p><a href="https://dokugakuexcel.com/%e3%80%90vba%e7%9f%a5%e8%ad%98-9%e3%80%91if-then%e3%81%a7%e6%9d%a1%e4%bb%b6%e5%88%86%e5%b2%90%e3%83%bb%e5%88%a4%e5%88%a5%e3%82%92%e3%81%99%e3%82%8b%e2%97%8b%e2%97%8b%e3%81%aa%e3%82%89/?preview_id=466&amp;preview_nonce=ed55e67214&amp;preview=true&amp;_thumbnail_id=470">【マクロ・VBA知識 9】If …Thenで条件分岐・判別をする(○○なら△△) ► 独学エクセル塾 (dokugakuexcel.com)</a></p>



<p>では実行した結果を見てみましょう。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-29.png" alt="" class="wp-image-2354" width="386" height="348" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-29.png 593w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-29-300x270.png 300w" sizes="(max-width: 386px) 100vw, 386px" /></figure>



<p>計画通り、機能してくれています。</p>



<h2 class="wp-block-heading"><span id="toc2">■カーソル行の前まで実行する方法について</span></h2>



<p>まずは<strong><span class="marker-under">カーソル行の前まで実行する方法</span></strong>について紹介したいと思います。<br>こちらの方法は動作確認が序盤で<strong><span class="marker-under">停止したい位置が毎回変化する場合に便利</span></strong>です。</p>



<p>再度、プログラムを図でみてみましょう。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-30.png" alt="" class="wp-image-2355" width="520" height="256" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-30.png 701w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-30-300x148.png 300w" sizes="(max-width: 520px) 100vw, 520px" /></figure>



<p>このプログラムのメインの機能は単価（C列）が空白でない場合、<br>単価（C列）と購入数(D列)をかける「Cells(Cycle, 5) = Cells(Cycle, 3) * Cells(Cycle, 4)」<br>の部分ですね。</p>



<p>しかし単価（C列）が空白な場合は対象の部分は飛ばされるので<br>何度も「F8」をおして実行しないといけません。<br>今回の見本は行数が少ないので問題ないですが、行数が多い場合は大変です。</p>



<p>では<strong><span class="marker-under-blue">「Cells(Cycle, 5) = Cells(Cycle, 3) * Cells(Cycle, 4)」の部分までプログラムを飛ばし、<br>対象のプログラムまで来たらプログラムを停止させてみましょう</span>。</strong></p>



<p>まず実行したいプログラムを選択し、「F8」を1回以上押して実行します。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-31.png" alt="" class="wp-image-2356" width="533" height="253" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-31.png 688w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-31-300x143.png 300w" sizes="(max-width: 533px) 100vw, 533px" /></figure>



<p>そして<strong><span class="marker-under-blue">止めたい行の部分で右クリック</span></strong>を押します。<br>ここでは「Cells(Cycle, 5) = Cells(Cycle, 3) * Cells(Cycle, 4)」の部分ですね。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-32.png" alt="" class="wp-image-2357" width="556" height="354" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-32-300x192.png 300w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-32-768x491.png 768w" sizes="(max-width: 556px) 100vw, 556px" /></figure>



<p>するとメニューに<strong><span class="marker-under-red">「カーソル行の前まで実行」</span></strong>という項目があります。<br>ではこちらを押してみましょう。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-33.png" alt="" class="wp-image-2358" width="521" height="244" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-33.png 693w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-33-300x140.png 300w" sizes="(max-width: 521px) 100vw, 521px" /></figure>



<p><strong><span class="marker-under-red">選択した行まで実行し、対象行で止まってくれました</span></strong>。<br>繰り返しの変数「Cycle」も4からスタートですがすでに「7」になってます。<br>つまり、「4～6」は空白で指定行が飛ばされたので、条件にあれはまる「7」で止まってくれました。</p>



<p>とても便利な機能ですね。</p>



<h2 class="wp-block-heading"><span id="toc3">■ブレークポイントを活用する</span></h2>



<p>では次の手法を見てみましょう。<br>使用する機能は<strong><span class="marker-under">「ブレークポイント」</span></strong>と呼ばれるものです。</p>



<p>こちらの手法は<strong><span class="marker-under">止めたい位置があらかじめ決まっている場合は<br>とても便利な機能</span></strong>です。</p>



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



<p>プログラムは先ほどと同様のプログラムを使用し、<br>計算結果を書き込む位置で止めたいと思います。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-34.png" alt="" class="wp-image-2359" width="458" height="225" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-34.png 701w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-34-300x148.png 300w" sizes="(max-width: 458px) 100vw, 458px" /></figure>



<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/03/image-35.png" alt="" class="wp-image-2360" width="502" height="232" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-35.png 749w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-35-300x139.png 300w" sizes="(max-width: 502px) 100vw, 502px" /></figure>



<p>この状態で<strong><span class="marker-under-red">「F9」</span></strong>を押してみましょう。<br>すると下図のように<strong><span class="marker-under-red">止めたい行の左に赤い印と対象行に色</span></strong>がつきました。<br>こちらが<strong><span class="marker-under">「ブレークポイント」</span></strong>と呼ばれる機能になります。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-36.png" alt="" class="wp-image-2361" width="505" height="238" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-36.png 696w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-36-300x141.png 300w" sizes="(max-width: 505px) 100vw, 505px" /></figure>



<p>ちなみにこちらの「ブレークポイント」は「F9」を押す以外にも設定することができます。</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:100%">
<p>その他の方法としては<br><strong><span class="marker-under-red">「ブレークポイント」の設定したい行の左のスペースを左クリック</span></strong>します。</p>
</div>
</div>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-37.png" alt="" class="wp-image-2362" width="670" height="260" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-37.png 861w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-37-300x117.png 300w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-37-768x299.png 768w" sizes="(max-width: 670px) 100vw, 670px" /></figure>



<p>こちらはワンクリックで設定できるのでとても便利ですね。</p>



<p>もう一つの方法として<br><strong><span class="marker-under-red">「ブレークポイント」</span></strong>を設定したい行を選択して<strong><span class="marker-under-red">「デバッグ」</span></strong>から<strong><span class="marker-under-red">「ブレークポイントの設定/解除」</span></strong>を<br>押しても設定可能です。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-38.png" alt="" class="wp-image-2363" width="478" height="360" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-38.png 710w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-38-300x226.png 300w" sizes="(max-width: 478px) 100vw, 478px" /></figure>



<p>では実際に「ブレークポイント」を活用してみましょう。</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-39.png" alt="" class="wp-image-2364" width="394" height="253" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-39.png 488w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-39-300x193.png 300w" sizes="(max-width: 394px) 100vw, 394px" /></figure>



<p>上記の状態で全実行の「Ｆ5」を押してみましょう。<br>結果はこのようになります。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="426" height="314" src="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-40.png" alt="" class="wp-image-2365" srcset="https://dokugakuexcel.com/wp-content/uploads/2022/03/image-40.png 426w, https://dokugakuexcel.com/wp-content/uploads/2022/03/image-40-300x221.png 300w" sizes="(max-width: 426px) 100vw, 426px" /></figure>



<p><strong><span class="marker-under-red">「ブレークポイント」の位置で止まってくれました</span></strong>。<br>繰り返し動作で指定の場所の処理を確認したい時など<br>止めたい位置がすでに判明している場合はとても便利な機能ですね。</p>



<p></p>



<h2 class="wp-block-heading"><span id="toc4">&#x2b1b;︎公式の説明</span></h2>



<p>わかりやすいように説明したため公式と使用する語句が異なりますが<br>マイクロソフト公式の説明については下記のリンクを参照してください。☟</p>



<p><a href="https://learn.microsoft.com/ja-jp/office/vba/language/how-to/set-and-clear-a-breakpoint">ブレークポイントの設定とクリア (VBA) | Microsoft Learn</a></p>



<h2 class="wp-block-heading"><span id="toc5">■まとめ</span></h2>



<p>いかがだったでしょうか。<br>動作確認（デバッグ）はプログラムが長ければ長いほど大変な作業です。</p>



<p>確認が終わっている個所を飛ばして実行したり、<br>ブレークポイントを活用して止めたい個所を止めたりすることで<br>動作確認（デバッグ）を効率よく実行してみてください。</p>



<p>それでは次回の記事でお会いしましょう。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://dokugakuexcel.com/%e3%80%90%e3%83%9e%e3%82%af%e3%83%advba%e7%9f%a5%e8%ad%98-28%e3%80%91%e6%8c%87%e5%ae%9a%e3%81%97%e3%81%9f%e4%bd%8d%e7%bd%ae%e3%81%be%e3%81%a7%e5%ae%9f%e8%a1%8c%e3%81%99%e3%82%8b%e3%83%96%e3%83%ac/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2352</post-id>	</item>
	</channel>
</rss>
