{"id":2923,"date":"2020-01-04T22:40:17","date_gmt":"2020-01-04T13:40:17","guid":{"rendered":"https:\/\/okamurax.com\/?p=2923"},"modified":"2020-01-13T17:11:25","modified_gmt":"2020-01-13T08:11:25","slug":"%e3%82%a8%e3%82%af%e3%82%bb%e3%83%abvba%e8%ac%9b%e5%ba%a7-%e5%88%9d%e5%9b%9e","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=2923","title":{"rendered":"VBA \u8b1b\u5ea7"},"content":{"rendered":"<p>\u30a8\u30af\u30bb\u30eb\u306b\u306fVBA\u3068\u3044\u3046\u958b\u767a\u74b0\u5883\u304c\u4ed8\u5c5e\u3057\u3066\u304a\u308a\u3001VBA\u3092\u6d3b\u7528\u3059\u308b\u3068\u30a8\u30af\u30bb\u30eb\u4e0a\u306e\u4f5c\u696d\u3092\u81ea\u52d5\u5316\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u5927\u624b\u4f01\u696d\u3067\u306f\u696d\u52d9\u3054\u3068\u306b\u5c02\u7528\u30bd\u30d5\u30c8\u3092\u5c0e\u5165\u3057\u3066\u3044\u305f\u308a\u3001\u958b\u767a\u306e\u5c02\u9580\u90e8\u7f72\u304c\u3042\u3063\u305f\u308a\u3057\u307e\u3059\u306e\u3067\u3001\u4e00\u822c\u306e\u5f93\u696d\u54e1\u304cVBA\u3092\u4f7f\u3046\u6a5f\u4f1a\u306f\u5c11\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u4e2d\u5c0f\u4f01\u696d\u3067\u306fVBA\u3092\u4f7f\u3046\u3068\u696d\u52d9\u3092\u52b9\u7387\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u79c1\u3082\u305d\u308c\u307b\u3069\u8a73\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u304c\u3001\u5b9f\u969b\u306b\u4eca\u307e\u3067\u3044\u304f\u3064\u304bVBA\u3092\u696d\u52d9\u306b\u5f79\u7acb\u3066\u3066\u304d\u307e\u3057\u305f\u306e\u3067\u3001\u3053\u3053\u3067\u306f\u305d\u306e\u7d4c\u9a13\u3092\u5206\u304b\u308a\u3084\u3059\u304f\u304a\u4f1d\u3048\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>VBA\u3092\u59cb\u3081\u308b\u306b\u3042\u305f\u3063\u3066\u4f55\u304c\u5927\u5909\u306a\u306e\u304b\u3068\u3044\u3046\u3068\u3001\u9762\u767d\u304f\u3082\u306a\u3044\u57fa\u790e\u77e5\u8b58\u3092\u899a\u3048\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002VBA\u306f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306e\u4e00\u7a2e\u306a\u306e\u3067\u3001\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u672a\u7d4c\u9a13\u306e\u4eba\u304b\u3089\u3059\u308b\u3068\u3001\u6700\u521d\u306b\u899a\u3048\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u5185\u5bb9\u3082\u304b\u306a\u308a\u306e\u91cf\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u3084\u308a\u305f\u3044\u3053\u3068\u306f\u660e\u78ba\u306a\u306e\u306b\u3001\u3059\u3050\u306b\u305d\u3053\u306b\u884c\u3051\u306a\u3044\u306e\u306f\u3082\u3069\u304b\u3057\u3044\u3082\u306e\u3067\u3059\u3002\u3067\u3059\u306e\u3067\u3001\u3053\u3053\u3067\u306f\u306a\u308b\u3079\u304f\u65e9\u304f\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u3053\u3068\u3092\u76ee\u6a19\u306b\u3057\u3066\u3001\u7d30\u304b\u3044\u90e8\u5206\u306f\u7701\u304d\u3001\u5fc5\u8981\u306a\u3053\u3068\u306f\u4f5c\u308a\u306a\u304c\u3089\u899a\u3048\u308c\u3070\u3044\u3044\u3068\u3044\u3046\u8003\u3048\u3067\u9032\u3081\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001VBA\u306a\u3069\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3067\u306f\u3084\u308a\u305f\u3044\u3053\u3068\u306b\u5bfe\u3057\u3066\u8907\u6570\u306e\u65b9\u6cd5\u304c\u5b58\u5728\u3059\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u308c\u3082\u3042\u3048\u3066\u4e00\u3064\u306e\u65b9\u6cd5\u3092\u63a1\u7528\u3057\u3066\u3057\u307e\u304a\u3046\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>VBA\u306e\u5b9f\u884c\u65b9\u6cd5<\/h2>\n<p><span style=\"color: #0000ff;\">\u958b\u767a\u30bf\u30d6\uff1e\u633f\u5165\uff1eActiveX\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\uff1e\u30b3\u30de\u30f3\u30c9\u30dc\u30bf\u30f3<\/span><br \/>\n\u8ffd\u52a0\u3055\u308c\u305f\u30b3\u30de\u30f3\u30c9\u30dc\u30bf\u30f3\u3092\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059\u3002<\/p>\n<p>VBA\u7528\u306e\u30a8\u30c7\u30a3\u30bf\u304c\u8868\u793a\u3055\u308c\u305f\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u8868\u793a\u3055\u308c\u305f<br \/>\n<span style=\"color: #0000ff;\">Private Sub CommandButton1_Click()<br \/>\n<\/span>\u3068<span style=\"color: #0000ff;\"><br \/>\nEnd Sub<\/span><br \/>\n\u306e\u9593\u306b\u51e6\u7406\u3092\u8a18\u5165\u3057\u3066\u3044\u304f\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3082\u3057\u958b\u767a\u30bf\u30d6\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u3001<br \/>\n<span style=\"color: #0000ff;\">\u30d5\u30a1\u30a4\u30eb\uff1e\u30aa\u30d7\u30b7\u30e7\u30f3\uff1e\u30ea\u30dc\u30f3\u306e\u30e6\u30fc\u30b6\u30fc\u8a2d\u5b9a<\/span><br \/>\n\u958b\u767a\u306b\u30c1\u30a7\u30c3\u30af\u3092\u4ed8\u3051\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3069\u3046\u3084\u3063\u3066VBA\u3092\u5b9f\u884c\u3059\u308b\u306e\u304b\uff1f\u3067\u3059\u304c\u3001\u958b\u767a\u30bf\u30d6\u306e\u4e2d\u306b\u30c7\u30b6\u30a4\u30f3\u30e2\u30fc\u30c9\u3068\u3044\u3046\u30dc\u30bf\u30f3\u304c\u3042\u308a\u3001\u3053\u308c\u304c\u62bc\u3055\u308c\u3066\u3044\u308b\u72b6\u614b\u3067\u306f\u4eca\u306e\u3088\u3046\u306bVBA\u306e\u30a8\u30c7\u30a3\u30bf\u304c\u958b\u304d\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30b6\u30a4\u30f3\u30e2\u30fc\u30c9\u306e\u30dc\u30bf\u30f3\u3092\u3082\u3046\u4e00\u5ea6\u62bc\u3059\u3068\u3001\u30c7\u30b6\u30a4\u30f3\u30e2\u30fc\u30c9\u304c\u62bc\u3055\u308c\u3066\u3044\u306a\u3044\u72b6\u614b\u306b\u306a\u308a\u3001\u305d\u306e\u72b6\u614b\u3067\u30b3\u30de\u30f3\u30c9\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068VBA\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u958b\u767a\u4e2d\u306b\u308f\u3056\u308f\u3056\u30dc\u30bf\u30f3\u3092\u62bc\u3055\u305a\u306b\u3001\u7d20\u65e9\u304f\u5b9f\u884c\u3057\u305f\u3044\u5834\u5408\u306f\u3001<br \/>\n<span style=\"color: #0000ff;\">Private Sub CommandButton1_Click()<br \/>\n<\/span>\u3068<span style=\"color: #0000ff;\"><br \/>\nEnd Sub<\/span><br \/>\n\u306e\u9593\u306b\u30ab\u30fc\u30bd\u30eb\u304c\u3042\u308b\u72b6\u614b\u3067\u3001VBA\u7528\u30a8\u30c7\u30a3\u30bf\u306e\u518d\u751f\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3053\u3068\u3067\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30bb\u30eb\u306b\u5024\u3092\u5165\u308c\u308b<\/h2>\n<p><span style=\"color: #0000ff;\">Sheets(&#8220;Sheet1&#8221;).Cells(1, 1).Value = &#8220;1&#8221;<\/span><\/p>\n<p>\u30bb\u30eb\u306b\u5024\u3092\u5165\u308c\u308b\u3068\u304d\u306f\u3053\u306e\u3088\u3046\u306b\u66f8\u304d\u307e\u3059\u3002\u3069\u306e\u30b7\u30fc\u30c8\u306a\u306e\u304b\u3001\u3069\u306e\u30bb\u30eb\u306a\u306e\u304b\u3092\u6307\u5b9a\u3057\u3001\u305d\u306e\u30bb\u30eb\u306e\u4e2d\u8eab\u3092Value\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u3001\u30bb\u30eb\u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u306e\u3060\u304b\u3089\u308f\u3056\u308f\u3056Value\u306f\u5fc5\u8981\u306a\u3044\u306e\u3067\u306f\uff1f\u3068\u601d\u3046\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002(\u5b9f\u969b\u306a\u304f\u3066\u3082\u52d5\u304f\u306e\u3067\u3059\u304c)\u306a\u305cValue\u304c\u5fc5\u8981\u306a\u306e\u304b\u3068\u3044\u3046\u3068\u3001\u30bb\u30eb\u306e\u5857\u308a\u3064\u3076\u3057\u306a\u3069\u30bb\u30eb\u306e\u4e2d\u8eab\u3068\u306f\u95a2\u4fc2\u306a\u3044\u90e8\u5206\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u3042\u308b\u306e\u3067\u3001\u4e2d\u8eab\u306fValue\u3067\u64cd\u4f5c\u3067\u304d\u308b\u3088\u3068\u899a\u3048\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u7d30\u304b\u304f\u307f\u3066\u3044\u304f\u3068\u3001<br \/>\n<span style=\"color: #0000ff;\">Sheets(&#8220;\u30b7\u30fc\u30c8\u540d&#8221;)<\/span><br \/>\n\u3067\u30b7\u30fc\u30c8\u540d\u3092\u6307\u5b9a\u3057\u3001<br \/>\n<span style=\"color: #0000ff;\">Cells(\u884c, \u5217)<\/span><br \/>\n\u3067\u4f55\u884c\u76ee\u306e\u4f55\u5217\u76ee\u306b\u3042\u308b\u30bb\u30eb\u306a\u306e\u304b\u3092\u6307\u5b9a\u3057\u3001<br \/>\n<span style=\"color: #0000ff;\">Value<\/span><br \/>\n\u3067\u6307\u5b9a\u3057\u305f\u30bb\u30eb\u306e\u5024\u3092\u64cd\u4f5c\u3067\u304d\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u306e\u30a4\u30b3\u30fc\u30eb\u306f\u4ee3\u5165(\u5165\u308c\u308b)\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u3002\u3064\u307e\u308aSheet1\u306e1\u884c\u76ee\u30671\u5217\u76ee\u306e\u30bb\u30eb\u306b&#8221;1&#8243;\u3092\u5165\u308c\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u3002<\/p>\n<h2>\u6570\u5024\u3068\u6587\u5b57<\/h2>\n<p>VBA\u3067\u306f\u6570\u5024\u3060\u3063\u305f\u3089\u305d\u306e\u307e\u307e\u76f4\u63a5(1\u306a\u3069)\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u6587\u5b57\u3060\u3063\u305f\u3089\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u56f2\u3046(&#8220;1&#8243;\u306a\u3069)\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u3067\u3082\u4eca\u56de1\u3092\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u56f2\u3063\u3066\u306a\u304b\u3063\u305f\uff1f\u3068\u601d\u3046\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u5c11\u3057\u96e3\u3057\u3044\u8a71\u3067\u3059\u304c\u30011\u3068&#8221;1&#8243;\u306f\u4e00\u822c\u7684\u306a\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3067\u306f\u6570\u5024\u306e1\u3068\u6587\u5b57\u306e1\u3068\u3057\u3066\u533a\u5225\u3055\u308c\u307e\u3059\u3002\u3044\u304f\u3064\u304b\u9055\u3044\u306f\u3042\u308a\u307e\u3059\u304c\u3001\u6570\u5024\u306e1\u306f\u56db\u5247\u6f14\u7b97\u3067\u304d\u3066\u3001\u6587\u5b57\u306e1\u306f\u56db\u5247\u6f14\u7b97\u3067\u304d\u306a\u3044\u3068\u3044\u3046\u3088\u3046\u306a\u9055\u3044\u304c\u3042\u308a\u307e\u3059\u3002\u3064\u307e\u308a\u4e0a\u8a18\u3067\u306f\u6570\u5024\u3067\u306f\u306a\u304f\u6587\u5b57\u306e1\u3092\u4ee3\u5165\u3057\u305f\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>VBA\u306e\u7279\u5fb4\u3068\u3057\u3066\u3001\u6587\u5b57\u306e\u6570\u5024(&#8220;1&#8243;\u306a\u3069)\u3067\u3082\u3001\u3069\u3046\u3084\u3089\u6570\u5024\u3068\u3057\u3066\u4f7f\u3063\u3066\u308b\u3063\u307d\u3044\u306a\u3068VBA\u304c\u5224\u65ad\u3059\u308b\u3068\u81ea\u52d5\u3067\u6570\u5024\u3068\u3057\u3066\u6271\u3063\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u3042\u305f\u308a\u3092\u6b63\u78ba\u306b\u7406\u89e3\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u578b\u3068\u3044\u3046\u3082\u306e\u304c\u51fa\u3066\u304d\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u4eca\u306f\u6570\u5024\u3068\u6587\u5b57\u306e\u9055\u3044\u306f\u3042\u308b\u3051\u3069\u3001VBA\u306f\u3044\u3044\u5177\u5408\u306b\u5224\u65ad\u3057\u3066\u304f\u308c\u308b\u7a0b\u5ea6\u306b\u7406\u89e3\u3057\u3066\u304a\u3051\u3070\u5927\u4e08\u592b\u3067\u3059\u3002<\/p>\n<h2>\u5024\u306e\u30b3\u30d4\u30fc<\/h2>\n<p>\u30bb\u30eb\u306e\u66f8\u5f0f\u3084\u6587\u5b57\u8272\u306a\u3069\u3082\u30b3\u30d4\u30fc\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001\u6700\u521d\u306f\u5024\u3060\u3051\u30b3\u30d4\u30fc\u3059\u308b\u65b9\u6cd5\u3092\u899a\u3048\u3066\u304a\u3051\u3070\u5927\u4e08\u592b\u3067\u3059\u3002Value\u3092\u4f7f\u3063\u3066\u30a4\u30b3\u30fc\u30eb\u3067\u4ee3\u5165\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<pre class=\"lang:vb decode:true\">Sheets(\"Sheet1\").Cells(1, 1).Value = Sheets(\"Sheet1\").Cells(2, 2).Value<\/pre>\n<h2>\u5024\u306e\u8868\u793a(MsgBox)<\/h2>\n<p>\u6b21\u306f\u30bb\u30eb\u306e\u5024\u3092\u8868\u793a\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #0000ff;\">MsgBox Sheets(&#8220;Sheet1&#8221;).Cells(1, 1).Value<\/span><\/p>\n<p>\u4ee3\u5165\u3067\u306f\u306a\u3044\u306e\u3067\u30a4\u30b3\u30fc\u30eb\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u4ee3\u308f\u308a\u306bMsgBox\u3068\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u3067\u6307\u5b9a\u3057\u305f\u5024\u3092\u30c0\u30a4\u30a2\u30ed\u30b0\u3067\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002Sheet1\u306e1\u884c\u76ee1\u5217\u76ee\u306e\u30bb\u30eb\u306e\u5024\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b<br \/>\n<span style=\"color: #0000ff;\">MsgBox &#8220;A&#8221;<\/span><br \/>\n\u306a\u3069\u306e\u3088\u3046\u306b\u8868\u793a\u3059\u308b\u5024\u3092\u76f4\u63a5\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>MsgBox\u306f\u30c7\u30d0\u30c3\u30b0\u3068\u3057\u3066\u3082\u5229\u7528\u3055\u308c\u307e\u3059\u3002\u4f8b\u3048\u3070\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u3063\u3066\u3044\u308b\u6700\u4e2d\u306b\u5909\u6570\u306e\u4e2d\u8eab\u3092\u78ba\u8a8d\u3057\u305f\u3044\u5834\u5408\u306a\u3069\u983b\u7e41\u306bMsgBox\u306f\u5229\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vb decode:true\">v = \"1\"\r\nMsgBox v\r\nv = \"2\"\r\nMsgBox v\r\n<\/pre>\n<h2>\u30eb\u30fc\u30d7(For\u6587)<\/h2>\n<p>\u30bb\u30eb\u306e\u5024\u3092\uff11\u3064\u305a\u3064\u8a2d\u5b9a\u3057\u305f\u308a\u53d6\u5f97\u3057\u305f\u308a\u3059\u308b\u3060\u3051\u3067\u306f\u624b\u4f5c\u696d\u3068\u5927\u304d\u306a\u9055\u3044\u306f\u3042\u308a\u307e\u305b\u3093\u3002VBA\u306e\u30e1\u30ea\u30c3\u30c8\u306f\u591a\u304f\u306e\u51e6\u7406\u3092\u81ea\u52d5\u5316\u3067\u304d\u308b\u3053\u3068\u3067\u3059\u304c\u3001\u30eb\u30fc\u30d7\u306f\u81ea\u52d5\u5316\u306e\u57fa\u672c\u306e\u4e00\u3064\u3067\u3059\u3002<\/p>\n<pre class=\"lang:vb decode:true\">For i = 1 To 10\r\nSheets(\"Sheet1\").Cells(i, 1).Value = i\r\nNext<\/pre>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068A\u5217\u306e1\uff5e10\u884c\u76ee\u306b1\uff5e10\u306e\u5024\u304c\u5165\u308a\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #0000ff;\">For \u5909\u6570 = \u958b\u59cb\u5024 to \u7d42\u4e86\u5024<\/span><br \/>\n<span style=\"color: #0000ff;\">\u3000\u51e6\u7406<\/span><br \/>\n<span style=\"color: #0000ff;\">Next<\/span><\/p>\n<p>\u3068\u3044\u3046\u306e\u304c\u57fa\u672c\u3067\u3059\u3002<\/p>\n<p>\u73fe\u6642\u70b9\u3067\u306f\u5909\u6570\u3068\u3044\u3046\u306e\u306f\u5165\u308c\u7269\u3068\u7406\u89e3\u3057\u3066\u304a\u3051\u3070\u5927\u4e08\u592b\u3067\u3059\u3002\u540d\u524d\u3082\u81ea\u7531\u306b\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u3053\u3053\u3067\u306fi\u3068\u3057\u3066\u3044\u307e\u3059\u304c\u3001counter\u306a\u3069\u3068\u3057\u3066\u3082\u5927\u4e08\u592b\u3067\u3059\u3002<\/p>\n<p>\u5909\u6570i\u306b\u306f1\u304b\u308910\u307e\u3067\u9806\u756a\u306b\u4ee3\u5165\u3055\u308c\u3001\u305d\u306e\u305f\u3073\u306b\u51e6\u7406\u304c\u5b9f\u884c\u3055\u308c\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002\u5177\u4f53\u7684\u306b\u3044\u3046\u3068<br \/>\n\u5909\u6570i\u304c1\u306e\u3068\u304d\u3001<br \/>\n<span style=\"color: #0000ff;\">Sheets(&#8220;Sheet1&#8221;).Cells(1, 1).Value = 1<\/span><br \/>\n\u3068\u3057\u3066\u51e6\u7406\u3055\u308c\u307e\u3059\u3002<br \/>\n\u5909\u6570i\u304c2\u306e\u3068\u304d\u3001<br \/>\n<span style=\"color: #0000ff;\">Sheets(&#8220;Sheet1&#8221;).Cells(2, 1).Value = 2<\/span><br \/>\n\u3068\u3057\u3066\u51e6\u7406\u3055\u308c\u307e\u3059\u3002<br \/>\n\u3053\u306e\u3088\u3046\u306b\u3001i\u304c10\u306b\u306a\u308b\u307e\u3067\u7e70\u308a\u8fd4\u3055\u308c\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u5909\u6570\u306f1\u304b\u3089\u306e\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3057\u3001\u51e6\u7406\u306e\u4e2d\u3067\u4f7f\u308f\u306a\u304f\u3066\u3082\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"lang:vb decode:true\">For i = 2 To 3\r\nMsgBox \"A\"\r\nNext\r\n<\/pre>\n<p>\u3053\u308c\u3060\u3068A\u304c2\u56de\u8868\u793a\u3055\u308c\u308b\u3060\u3051\u3067\u3059\u3002\u51e6\u7406\u3067i\u306f\u4f7f\u3063\u3066\u3044\u307e\u305b\u3093\u3002\u30eb\u30fc\u30d7\u30922\u56de\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<h2>\u6761\u4ef6<\/h2>\n<p>\u6b21\u306b\u8aac\u660e\u3059\u308bDo-While\u3068If\u3067\u6761\u4ef6\u3068\u3044\u3046\u306e\u304c\u3067\u3066\u304d\u307e\u3059\u3002\u6761\u4ef6\u3068\u306f2\u3064\u306e\u5909\u6570\u3042\u308b\u3044\u306f\u76f4\u63a5\u306e\u5024\u3092\u6307\u5b9a\u3057\u3001\u305d\u306e2\u3064\u306e\u9593\u306b\u4e0b\u8a18\u306e\u5f0f\u3092\u66f8\u3044\u3066\u305d\u308c\u304c\u6e80\u305f\u3055\u308c\u305f\u5834\u5408\u3001True(\u51e6\u7406\u306e\u5b9f\u884c)\u3068\u306a\u308a\u3001\u6e80\u305f\u3055\u308c\u306a\u3044\u5834\u5408\u3001False(\u51e6\u7406\u304c\u5b9f\u884c\u3055\u308c\u306a\u3044)\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u6761\u4ef6\u306f<br \/>\n<span style=\"color: #0000ff;\">A\u00a0 =\u00a0 B (A\u3068B\u304c\u540c\u3058)<\/span><br \/>\n<span style=\"color: #0000ff;\">A &lt;&gt; B (A\u3068B\u304c\u9055\u3046)<\/span><br \/>\n<span style=\"color: #0000ff;\">A &gt;= B (A\u304cB\u4ee5\u4e0a)<\/span><br \/>\n<span style=\"color: #0000ff;\">A &lt;= B (A\u304cB\u4ee5\u4e0b)<\/span><br \/>\n<span style=\"color: #0000ff;\">A\u00a0 &gt;\u00a0 B (A\u304cB\u3088\u308a\u5927\u304d\u3044)<\/span><br \/>\n<span style=\"color: #0000ff;\">A\u00a0 &lt;\u00a0 B (A\u304cB\u3088\u308a\u5c0f\u3055\u3044)<br \/>\n<span style=\"color: #333333;\">\u306e\u3088\u3046\u306a\u7a2e\u985e\u304c\u3042\u308a\u307e\u3059\u3002<\/span><\/span><\/p>\n<p>\u5b9f\u969bA\u3068B\u306b\u306f\u5909\u6570\u304b\u5024\u304c\u5165\u308a\u307e\u3059\u3002<br \/>\n<span style=\"color: #0000ff;\">\u5909\u6570\u3000\u6761\u4ef6\u3000\u5909\u6570<\/span><br \/>\n<span style=\"color: #0000ff;\">\u5909\u6570\u3000\u6761\u4ef6\u3000\u3000\u5024<\/span><br \/>\n<span style=\"color: #0000ff;\">\u3000\u5024\u3000\u6761\u4ef6\u3000\u5909\u6570<\/span><br \/>\n<span style=\"color: #0000ff;\">\u3000\u5024\u3000\u6761\u4ef6\u3000\u3000\u5024<\/span><br \/>\n\u3044\u305a\u308c\u306e\u7d44\u307f\u5408\u308f\u305b\u3066\u3067\u3082\u5927\u4e08\u592b\u3067\u3059\u3002<\/p>\n<p>\u6761\u4ef6\u306fOr\u3068And\u3092\u4f7f\u3046\u3053\u3068\u3067\u8907\u6570\u540c\u6642\u306b\u4f7f\u3046\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002\u610f\u5473\u306f\u305d\u306e\u307e\u307e\u3001Or\u3067\u3042\u308c\u3070\u3069\u3061\u3089\u304b\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3059\u3001And\u3067\u3042\u308c\u3070\u4e21\u65b9\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3059\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070<br \/>\n<span style=\"color: #0000ff;\">c = 5 Or r = 5<\/span><br \/>\n\u3067\u3042\u308c\u3070\u3001c\u3068\u3044\u3046\u5909\u6570\u306e\u4e2d\u306b5\u304c\u5165\u3063\u3066\u3044\u308b\u72b6\u614b\u304b\u3001r\u3068\u3044\u3046\u5909\u6570\u306e\u4e2d\u306b5\u304c\u5165\u3063\u3066\u3044\u308b\u72b6\u614b\u306e\u3069\u3061\u3089\u304b\u4e00\u65b9\u3067True\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #0000ff;\">c = 5 And r = 5<\/span><br \/>\n\u3067\u3042\u308c\u3070\u3001c\u3068\u3044\u3046\u5909\u6570\u306e\u4e2d\u306b5\u304c\u5165\u3063\u3066\u3044\u308b\u72b6\u614b\u3067\u3042\u308a\u3001r\u3068\u3044\u3046\u5909\u6570\u306e\u4e2d\u306b\u30825\u304c\u5165\u3063\u3066\u3044\u308b\u72b6\u614b\u3067\u306f\u3058\u3081\u3066True\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30eb\u30fc\u30d7(Do-While\u6587)<\/h2>\n<p><span style=\"color: #0000ff;\">Do While \u6761\u4ef6<\/span><br \/>\n<span style=\"color: #0000ff;\">\u3000\u51e6\u7406<\/span><br \/>\n<span style=\"color: #0000ff;\">Loop<\/span><br \/>\n\u304c\u57fa\u672c\u3067\u3059\u3002<\/p>\n<p>\u6761\u4ef6\u304c\u6e80\u305f\u3055\u308c\u3066\u3044\u308b\u9593\u51e6\u7406\u3092\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vb decode:true\">i = 1\r\nDo While i &lt;= 3\r\n  MsgBox i\r\n  i = i + 1\r\nLoop\r\n<\/pre>\n<p>\u3053\u308c\u30671\u304b\u30893\u307e\u3067\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u540c\u3058\u30eb\u30fc\u30d7\u3067For\u3068\u4f55\u304c\u9055\u3046\u306e\uff1f\u3068\u601d\u3046\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u5b9f\u969b\u3001\u540c\u3058\u3053\u3068\u3092\u3057\u3088\u3046\u3068\u601d\u3048\u3070\u3069\u3061\u3089\u3092\u4f7f\u3063\u3066\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f7f\u3044\u5206\u3051\u3068\u3057\u3066\u3001\u30c7\u30fc\u30bf\u91cf\u304c\u56fa\u5b9a\u306e\u7bc4\u56f2\u3092\u30eb\u30fc\u30d7\u3055\u305b\u308b\u5834\u5408\u306fFor\u3092\u4f7f\u3044\u3001\u30c7\u30fc\u30bf\u304c\u3069\u3093\u3069\u3093\u8ffd\u52a0\u3055\u308c\u3066\u3044\u304f\u3088\u3046\u306a\u30bf\u30a4\u30d7\u306e\u7bc4\u56f2\u3092\u30eb\u30fc\u30d7\u3055\u305b\u308b\u5834\u5408\u306fDo-While\u3092\u4f7f\u3046\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002<\/p>\n<h2>\u6761\u4ef6\u5206\u5c90(If\u6587)<\/h2>\n<p>\u3042\u308b\u6761\u4ef6\u304c\u6e80\u305f\u3055\u308c\u308b\u5834\u5408\u306e\u307f\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #0000ff;\">If \u6761\u4ef6 Then<\/span><br \/>\n<span style=\"color: #0000ff;\">\u3000\u51e6\u7406<\/span><br \/>\n<span style=\"color: #0000ff;\">End If<\/span><br \/>\n\u304c\u57fa\u672c\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vb decode:true\">Sub test()\r\n\r\nIf 5 &gt;= 5 Then\r\n  MsgBox \"Hello\" '\u8868\u793a\u3055\u308c\u308b\r\nEnd If\r\n\r\nIf 5 &gt; 5 Then\r\n  MsgBox \"World\" ' \u8868\u793a\u3055\u308c\u306a\u3044\r\nEnd If\r\n\r\nIf \"5\" &gt;= 5 Then\r\n  MsgBox \"!!!\" ' \u8868\u793a\u3055\u308c\u308b\r\nEnd If\r\n\r\nEnd Sub<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u65e2\u306b\u5c11\u3057\u8aac\u660e\u3057\u307e\u3057\u305f\u304c\u3001VBA\u3067\u306f\u6587\u5b57\u3068\u6570\u5024\u3092\u3046\u307e\u3044\u5177\u5408\u306b\u6271\u3063\u3066\u304f\u308c\u307e\u3059\u3002\u4e00\u822c\u7684\u306a\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3067\u306f\u6570\u5024\u3068\u6587\u5b57\u306f\u6bd4\u8f03\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u4f8b\u3048\u3070&#8221;5&#8243;\u30685\u306f\u6bd4\u8f03\u3067\u304d\u307e\u305b\u3093\u3002\u3053\u306e\u8fba\u308a\u306e\u7279\u5fb4\u306f\u5c11\u3057\u610f\u8b58\u3057\u3066\u304a\u3044\u305f\u307b\u3046\u304c\u3044\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>If\u6587\u3067\u306f\u3060\u3044\u305f\u3044\u540c\u6642ElseIf\u3084Else\u3082\u8aac\u660e\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u4eca\u306e\u6bb5\u968e\u3067\u306f\u4f7f\u308f\u306a\u304f\u3066\u3082\u5927\u4e08\u592b\u3067\u3059\u3002<\/p>\n<h2>\u5b9f\u7528\u4f8b<\/h2>\n<p>\u3053\u3053\u307e\u3067\u306e\u8aac\u660e\u3067\u5c11\u3057\u5b9f\u7528\u7684\u306a\u3082\u306e\u3092\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002Sheet1\u306e\u30c7\u30fc\u30bf\u306b\u6761\u4ef6\u30921\u3064\u901a\u3057\u3066Sheet2\u306b\u30b3\u30d4\u30fc\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>Sheet1\u306b\u306f2\u5217\u30c7\u30fc\u30bf\u304c\u5165\u3063\u3066\u3044\u3066\u30011\u5217\u76ee\u306b\u306f\u540d\u79f0\u30012\u5217\u76ee\u306b\u306f\u6570\u91cf\u3092\u5165\u308c\u3066\u3042\u308a\u307e\u3059\u30021\u5217\u76ee\u304c\u7a7a\u767d\u306b\u306a\u308b\u307e\u3067\u30eb\u30fc\u30d7\u3057\u30012\u5217\u76ee\u304c0\u306e\u5834\u5408\u306f\u30b3\u30d4\u30fc\u3057\u306a\u3044\u3068\u3044\u3046\u51e6\u7406\u3092\u304a\u3053\u306a\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vb decode:true \">targetRow = 1 '\u66f8\u304d\u8fbc\u307f\u5bfe\u8c61\u884c\r\n\r\nr = 2\r\nDo While Sheets(\"Sheet1\").Cells(r, 1).Value &lt;&gt; \"\"\r\n\r\n  n = Sheets(\"Sheet1\").Cells(r, 1).Value\r\n  q = Sheets(\"Sheet1\").Cells(r, 2).Value\r\n  \r\n  If q &lt;&gt; \"0\" Then\r\n    \r\n    Sheets(\"Sheet2\").Cells(targetRow, 1).Value = n\r\n    Sheets(\"Sheet2\").Cells(targetRow, 2).Value = q\r\n    rr = rr + 1\r\n    \r\n  End If\r\n  \r\n  r = r + 1\r\nLoop<\/pre>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/l551tDBOy_Q\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>\u975e\u5e38\u306b\u7c21\u5358\u306a\u4f8b\u3067\u3059\u304c\u3001\u624b\u4f5c\u696d\u3067\u306f\u56f0\u96e3\u306a\u7a0b\u5ea6\u306e\u91cf\u306b\u306a\u3063\u3066\u304f\u308b\u3068\u81ea\u52d5\u5316\u304c\u5f79\u306b\u7acb\u3064\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a8\u30af\u30bb\u30eb\u306b\u306fVBA\u3068\u3044\u3046\u958b\u767a\u74b0\u5883\u304c\u4ed8\u5c5e\u3057\u3066\u304a\u308a\u3001VBA\u3092\u6d3b\u7528\u3059\u308b\u3068\u30a8\u30af\u30bb\u30eb\u4e0a\u306e\u4f5c\u696d\u3092\u81ea\u52d5\u5316\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u5927\u624b\u4f01\u696d\u3067\u306f\u696d\u52d9\u3054\u3068\u306b\u5c02\u7528\u30bd\u30d5\u30c8\u3092\u5c0e\u5165\u3057\u3066\u3044\u305f\u308a\u3001\u958b\u767a\u306e\u5c02\u9580\u90e8\u7f72\u304c\u3042\u3063\u305f\u308a\u3057\u307e\u3059\u306e\u3067\u3001\u4e00\u822c\u306e\u5f93\u696d\u54e1\u304cV &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=2923\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;VBA \u8b1b\u5ea7&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[5],"class_list":["post-2923","post","type-post","status-publish","format-standard","hentry","category-1","tag-vba"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2923"}],"version-history":[{"count":41,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2923\/revisions"}],"predecessor-version":[{"id":5089,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2923\/revisions\/5089"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}