{"id":5890,"date":"2025-11-25T16:15:17","date_gmt":"2025-11-25T07:15:17","guid":{"rendered":"https:\/\/www.bold.ne.jp\/engineer-club\/?p=5890"},"modified":"2025-10-08T16:08:59","modified_gmt":"2025-10-08T07:08:59","slug":"vba_fornext","status":"publish","type":"post","link":"https:\/\/www.bold.ne.jp\/engineer-club\/vba_fornext","title":{"rendered":"VBA\u306efor\uff5eNext\u3068\u306f\uff1f\u89e3\u8aac\u3068\u4f7f\u7528\u4f8b"},"content":{"rendered":"<p>\u306f\u3058\u3081\u306b\u2026<br \/>\n\u65e5\u5e38\u3084\u4ed5\u4e8b\u3067\u3001\u300c\u5358\u7d14\u306a\u540c\u3058\u4f5c\u696d\u3092\u4f55\u56de\u3082\u7e70\u308a\u8fd4\u3057\u3057\u3066\u3044\u308b\u306a\u3041\u300d\u3068\u601d\u3063\u305f\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u304b\uff1f<\/p>\n<p>VBA\u306efor\u6587\u3092\u4f7f\u3046\u3068\u3001\u77ed\u6642\u9593\u3067\u4f5c\u696d\u3092\u7d42\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<br \/>\nfor\u6587\u306b\u306f\u3001\u4e3b\u306b\u300cfor\uff5eNext\u300d\u300cfor\uff5eEach\u300d\u306e2\u7a2e\u985e\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u4f7f\u3044\u5206\u3051\u3068\u3057\u3066\u306f\u3001\u300cfor\uff5eNext\u300d\u306f\u300c\u3007\u56de\u51e6\u7406\u3092\u7e70\u308a\u8fd4\u3057\u305f\u3044\u300d\u3001\u300cfor\uff5eEach\u300d\u306f\u300c\u914d\u5217\u3084\u6307\u5b9a\u3057\u305f\u30bb\u30eb\u306e\u5024\u3092\u9806\u756a\u306b\u51e6\u7406\u3092\u7e70\u308a\u8fd4\u3057\u305f\u3044\u300d\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f\u300cfor Next\u300d\u306e\u89e3\u8aac\u3092\u884c\u3044\u3001\u305d\u306e\u4f7f\u3044\u65b9\u3092\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#forNext\">\uff11\uff0efor\uff5eNext\u6587\u306b\u3064\u3044\u3066<\/a><ul><li><a href=\"#-forNext\">\uff11-\uff11\uff0efor\uff5eNext\u6587\u3068\u306f<\/a><\/li><li><a href=\"#-forNext-2\">\uff11-\uff12\uff0efor\uff5eNext\u6587\u306e\u69cb\u6587<\/a><\/li><\/ul><\/li><li><a href=\"#forNext-2\">\uff12\uff0efor\uff5eNext\u6587\u306e\u4f7f\u7528\u4f8b<\/a><ul><li><a href=\"#i\">\uff12-\uff11\uff0e\u57fa\u672c\u7684\u306a\u4f7f\u7528\u4f8b<\/a><\/li><li><a href=\"#i-2\">\uff12\uff70\uff12\uff70\uff11\uff0e\u6307\u5b9a\u3057\u305f\u56de\u6570\u5206\u3001\u51e6\u7406\u3092\u7e70\u308a\u8fd4\u3059<\/a><\/li><li><a href=\"#i-3\">\uff12\uff70\uff12\uff70\uff12\uff0e\u7279\u5b9a\u306e\u6761\u4ef6\u3067\u7e70\u308a\u8fd4\u3057\u3092\u7d42\u4e86\u3059\u308b<\/a><\/li><li><a href=\"#i-4\">\uff12-\uff13\uff0e\u305d\u306e\u4ed6\u306e\u4f7f\u7528\u4f8b<\/a><\/li><\/ul><\/li><li><a href=\"#i-5\">\uff13\uff0e\u6ce8\u610f\u70b9<\/a><\/li><li><a href=\"#i-6\">\uff14\uff0e\u6700\u5f8c\u306b<\/a><\/li><\/ul><\/div>\n<h2><span id=\"forNext\">\uff11\uff0efor\uff5eNext\u6587\u306b\u3064\u3044\u3066<\/span><\/h2>\n<h3><span id=\"-forNext\">\uff11-\uff11\uff0efor\uff5eNext\u6587\u3068\u306f<\/span><\/h3>\n<p>\u30c4\u30fc\u30eb\u7b49\u3092\u4f5c\u6210\u3057\u3066\u3044\u3066\u3001\u540c\u3058\u547d\u4ee4\u3092\u4f55\u56de\u3082\u7e70\u308a\u8fd4\u3059\u3068\u304d\u306f\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u304b\uff1f<br \/>\nfor\uff5eNext\u6587\u306f\u3001\u300c\u3042\u308b\u547d\u4ee4\u3092\u6307\u5b9a\u3057\u305f\u56de\u6570\u3060\u3051\u7e70\u308a\u8fd4\u3059\u300d\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3><span id=\"-forNext-2\">\uff11-\uff12\uff0efor\uff5eNext\u6587\u306e\u69cb\u6587<\/span><\/h3>\n<p>for\uff5eNext\u6587\u306e\u57fa\u672c\u7684\u306a\u69cb\u6587\u306f\u4e0b\u8a18\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\nStep\u306f\u7701\u7565\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">Sub main()\r\n  Dim i As Integer\r\n  For i = [\u958b\u59cb\u3059\u308b\u5024] To [\u7d42\u4e86\u3059\u308b\u5024] Step [\u52a0\u7b97\uff08\u6e1b\u7b97\uff09\u3059\u308b\u5024]\r\n    [\u7e70\u308a\u8fd4\u3057\u305f\u3044\u547d\u4ee4]\r\n  Next i      '\u52a0\u7b97\uff08\u6e1b\u7b97\uff09\u3059\u308b\u5909\u6570\uff08\u5909\u6570\u306e\u307f\u306e\u5834\u5408\u3001+1\u3055\u308c\u308b\uff09\r\nEnd Sub\r\n<\/pre>\n<h2><span id=\"forNext-2\">\uff12\uff0efor\uff5eNext\u6587\u306e\u4f7f\u7528\u4f8b<\/span><\/h2>\n<h3><span id=\"i\">\uff12-\uff11\uff0e\u57fa\u672c\u7684\u306a\u4f7f\u7528\u4f8b<\/span><\/h3>\n<p>for\uff5eNext\u3067\u56f2\u307e\u308c\u305f\u51e6\u7406\u3092\u3001\u300c\u958b\u59cb\u3059\u308b\u5024\u300d\u304b\u3089\u300c\u7d42\u4e86\u3059\u308b\u5024\u300d\u307e\u3067\u7e70\u308a\u8fd4\u3057\u307e\u3059\u3002<br \/>\n\u3088\u304f\u4f7f\u7528\u3055\u308c\u308b\u306e\u306f\u300cA\u304b\u3089B\u307e\u3067\u306e\u56de\u6570\u3092\u7e70\u308a\u8fd4\u3059\u300d\u3067\u3059\u304c\u3001<span class=\"f-marker-p\">\u6b63\u78ba\u306b\u306f\u300cA\u304b\u3089C\u306e\u6570\u3060\u3051\u52a0\u7b97\uff08\u6e1b\u7b97\uff09\u3057\u3066B\u3092\u8d85\u3048\u308b\u307e\u3067\u7e70\u308a\u8fd4\u3059\u300d\u306b\u306a\u308a\u307e\u3059\u3002<\/span><\/p>\n<h3><span id=\"i-2\">\uff12\uff70\uff12\uff70\uff11\uff0e\u6307\u5b9a\u3057\u305f\u56de\u6570\u5206\u3001\u51e6\u7406\u3092\u7e70\u308a\u8fd4\u3059<\/span><\/h3>\n<p>0\uff5e3\u307e\u3067\u306e\u5024\u30925\u500d\u3057\u305f\u5408\u8a08\u5024\u3092\u51fa\u529b\u3059\u308b\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">Sub main02()\r\n  Dim i As Integer\r\n  Dim cnt As Integer\r\n  For i = 0 To 3\r\n    cnt = cnt + i * 5\r\n  Next i\r\n  MsgBox cnt\r\nEnd Sub\r\n<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<a href=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2025\/10\/\u3044.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2025\/10\/\u3044.png\" alt=\"\u7d50\u679c\" width=\"160\" height=\"186\" class=\"alignnone size-full wp-image-5891\" \/><\/a><\/p>\n<h3><span id=\"i-3\">\uff12\uff70\uff12\uff70\uff12\uff0e\u7279\u5b9a\u306e\u6761\u4ef6\u3067\u7e70\u308a\u8fd4\u3057\u3092\u7d42\u4e86\u3059\u308b<\/span><\/h3>\n<p>0\uff5e3\u307e\u3067\u306e\u5024\u30925\u500d\u3057\u305f\u5408\u8a08\u5024\u3092\u51fa\u529b\u3059\u308b\u3002<br \/>\n\u5408\u8a08\u5024\u304c9\u3092\u8d85\u3048\u308b\u3068\u3001\u9014\u4e2d\u3067\u7d42\u4e86\u3059\u308b\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">Sub main03()\r\n  Dim i As Integer\r\n  Dim cnt As Integer\r\n  For i = 0 To 3\r\n    cnt = cnt + i * 5\r\n    If cnt &gt; 9 Then\r\n      Exit For            'cnt\u306e\u5024\u304c9\u3092\u8d85\u3048\u3066\u3044\u308b\u5834\u5408\u3001for\u6587\u3092\u629c\u3051\u308b\r\n    End If\r\n  Next i\r\n  MsgBox cnt\r\nEnd Sub<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<a href=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2025\/10\/\u3046.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2025\/10\/\u3046.png\" alt=\"\u7d50\u679c\uff12\" width=\"160\" height=\"186\" class=\"alignnone size-full wp-image-5892\" \/><\/a><\/p>\n<h3><span id=\"i-4\">\uff12-\uff13\uff0e\u305d\u306e\u4ed6\u306e\u4f7f\u7528\u4f8b<\/span><\/h3>\n<p>for\u6587\u306e\u300cTo\u300d\u306e\u5f8c\u306b\u300cStep\u300d\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067\u3001\u7e70\u308a\u8fd4\u3057\u306e\u52a0\u7b97\u3084\u6e1b\u7b97\u306e\u5024\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u4f8b\uff091\u304b\u308910\u307e\u3067\u306e\u5947\u6570\u306e\u5408\u8a08\u3092\u51fa\u529b<\/p>\n<pre class=\"prettyprint lang:default decode:true\">Sub main04()\r\n  Dim i As Integer\r\n  Dim cnt As Integer\r\n  For i = 1 To 10 Step 2\r\n    cnt = cnt + i\r\n  Next i\r\n  MsgBox cnt\r\nEnd Sub\r\n<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<a href=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2025\/10\/\u3048.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2025\/10\/\u3048.png\" alt=\"\u7d50\u679c\" width=\"160\" height=\"186\" class=\"alignnone size-full wp-image-5893\" \/><\/a><\/p>\n<h2><span id=\"i-5\">\uff13\uff0e\u6ce8\u610f\u70b9<\/span><\/h2>\n<p>\u4e0b\u8a18\u30bd\u30fc\u30b9\u306e\u5834\u5408\u3001\u6307\u5b9a\u3057\u305f\u5024\u306e\u9593\u3060\u3051\uff08\u4e0b\u8a18\u3067\u306f\u300c0\u300d\uff5e\u300c3\u300d\uff09\u306e\u51e6\u7406\u3092\u7e70\u308a\u8fd4\u3057\u307e\u3059\u3002<br \/>\n\u305d\u306e\u5f8c\u30013\u56de\u76ee\u306eNext\u51e6\u7406\u3092\u884c\u3044\u3001For\u6587\u3067\u5909\u6570i\u306e\u5024\u3092\u30c1\u30a7\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001for\u6587\u3092\u629c\u3051\u305f\u3068\u304d\u306e\u5909\u6570i\u306e\u5024\u306f\u3001\u300c\u7d42\u4e86\u3059\u308b\u5024\u300d<\/p>\n<pre class=\"prettyprint lang:default decode:true\">Sub main05()\r\n  Dim i As Integer\r\n  Dim cnt As Integer\r\n  For i = 0 To 3\r\n    \u2018[\u7e70\u308a\u8fd4\u3057\u305f\u3044\u51e6\u7406]\r\n  Next i\r\n  MsgBox i\r\nEnd Sub\r\n<\/pre>\n<p>\n\u5b9f\u884c\u7d50\u679c\uff1a<a href=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2025\/10\/\u304a.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2025\/10\/\u304a.png\" alt=\"\u7d50\u679c\" width=\"160\" height=\"186\" class=\"alignnone size-full wp-image-5894\" \/><\/a><\/p>\n<h2><span id=\"i-6\">\uff14\uff0e\u6700\u5f8c\u306b<\/span><\/h2>\n<p>for\uff5eNext\u6587\u306f\u3001VBA\u4ee5\u5916\u306e\u8a00\u8a9e\u3067\u3082\u3088\u304f\u4f7f\u7528\u3055\u308c\u308b\u7e70\u308a\u8fd4\u3057\u51e6\u7406\u3067\u3059\u3002<br \/>\n\u4f7f\u3044\u3053\u306a\u3059\u3053\u3068\u3067\u3001\u540c\u3058\u5185\u5bb9\u3092\u7e70\u308a\u8fd4\u3057\u884c\u3046\u4f5c\u696d\u306e\u6642\u9593\u77ed\u7e2e\u3092\u56f3\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\n\u305c\u3072\u3001\u6d3b\u7528\u3057\u3066\u3044\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b\u2026 \u65e5\u5e38\u3084\u4ed5\u4e8b\u3067\u3001\u300c\u5358\u7d14\u306a\u540c\u3058\u4f5c\u696d\u3092\u4f55\u56de\u3082\u7e70\u308a\u8fd4\u3057\u3057\u3066\u3044\u308b\u306a\u3041\u300d\u3068\u601d\u3063\u305f\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u304b\uff1f VBA\u306efor\u6587\u3092\u4f7f\u3046\u3068\u3001\u77ed\u6642\u9593\u3067\u4f5c\u696d\u3092\u7d42\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002 for\u6587\u306b\u306f\u3001\u4e3b\u306b\u300cfor\uff5eNext\u300d\u300cf [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":3059,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18,11],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/5890"}],"collection":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/comments?post=5890"}],"version-history":[{"count":5,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/5890\/revisions"}],"predecessor-version":[{"id":5961,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/5890\/revisions\/5961"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media\/3059"}],"wp:attachment":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media?parent=5890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/categories?post=5890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}