{"id":164,"date":"2017-07-10T13:10:58","date_gmt":"2017-07-10T04:10:58","guid":{"rendered":"https:\/\/jidouka.work\/?p=164"},"modified":"2017-07-10T13:10:58","modified_gmt":"2017-07-10T04:10:58","slug":"excel%e3%82%b7%e3%83%bc%e3%83%88%e3%81%ab%e5%85%a5%e5%8a%9b%e5%86%85%e5%ae%b9%e3%83%aa%e3%82%bb%e3%83%83%e3%83%88%e3%83%9c%e3%82%bf%e3%83%b3%e3%82%92%e3%81%a4%e3%81%91%e3%82%8bvba","status":"publish","type":"post","link":"https:\/\/jidouka.work\/?p=164","title":{"rendered":"Excel\u30b7\u30fc\u30c8\u306b\u5165\u529b\u5185\u5bb9\u30ea\u30bb\u30c3\u30c8\u30dc\u30bf\u30f3\u3092\u3064\u3051\u308b[VBA]"},"content":{"rendered":"<p>\u30a8\u30af\u30bb\u30eb\u306e\u30b7\u30fc\u30c8\u306b\u5165\u529b\u3092\u884c\u306a\u3063\u305f\u5f8c\u306b\u5165\u529b\u5185\u5bb9\u3092\u30af\u30ea\u30a2\u3057\u305f\u3044\u3068\u3044\u3046\u5834\u5408\u306f\u3088\u304f\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u3053\u3053\u3067\u5165\u529b\u3057\u305f\u7b87\u6240\u3092\u9078\u3093\u3067Delete\u30ad\u30fc\u3067\u6d88\u3057\u305f\u308a\u30010\u3067\u57cb\u3081\u308b\u306a\u3093\u3066\u65b9\u6cd5\u3067\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u6d88\u3057\u5fd8\u308c\u304c\u3042\u3063\u305f\u308a\u3001\u8907\u6570\u306e\u30b7\u30fc\u30c8\u306b\u307e\u305f\u304c\u3063\u3066\u6d88\u53bb\u3059\u308b\u3068\u306a\u308b\u3068\u82e5\u5e72\u624b\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u78ba\u5b9f\u304b\u3064\u7c21\u5358\u306b\u5165\u529b\u5185\u5bb9\u3092\u6d88\u3059\u305f\u3081\u306bVBA\u30de\u30af\u30ed\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b7\u30fc\u30c8\u306e\u7528\u610f<\/h2>\n<p><a href=\"https:\/\/jidouka.work\/?p=150\">\u524d\u56de\u3001\u5546\u54c1\u9805\u76ee\u3092\u81ea\u52d5\u7684\u306b\u8a70\u3081\u3066\u304f\u308c\u308b\u898b\u7a4d\u66f8\u3067\u4f7f\u7528\u3057\u305f\u30b7\u30fc\u30c8<\/a>\u3092\u6539\u826f\u3057\u307e\u3059\u3002<\/p>\n<h2>\u5165\u529b\u5185\u5bb9\u30ea\u30bb\u30c3\u30c8\u7528\u306e\u30b3\u30fc\u30c9<\/h2>\n<p>\u4eca\u56de\u306f\u65b0\u3057\u304freset\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3068\u898b\u7a4d\u66f8\u306e\u30ea\u30b9\u30c8\u3092\u6d88\u53bb\u3059\u308b\u305f\u3081\u306eclearQuotation\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u307e\u305f\u898b\u7a4d\u66f8\u306e\u30ea\u30b9\u30c8\u306b\u9805\u76ee\u3092\u57cb\u3081\u308b\u305f\u3081\u306e\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u306ffillOutQuotation\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<figure class=\"jd-code\"><button type=\"button\" class=\"jd-code-copy\">\u30b3\u30d4\u30fc<\/button><pre><code class=\"language-vbnet\">Option Explicit\r\n\r\n&#039;\u5546\u54c1\u30ea\u30b9\u30c8\u306e\u6700\u521d\u306e\u884c\r\nConst firstRow As Integer = 2\r\n&#039;\u5546\u54c1\u30ea\u30b9\u30c8\u306e\u6700\u5f8c\u306e\u884c\r\nConst lastRow As Integer = 6\r\n&#039;\u898b\u7a4d\u66f8\u306e\u6700\u521d\u306e\u884c\r\nConst quoFirstRow As Long = 24\r\n\r\nSub fillOutQuotation()\r\n    Dim i As Long\r\n    \r\n    Call clearQuotation\r\n    \r\n&#039;    \u898b\u7a4d\u66f8\u306e\u5546\u54c1\u30ea\u30b9\u30c8\u306e\u6700\u521d\u306e\u884c\u3092\u30bb\u30c3\u30c8\u3059\u308b\r\n    Dim currentQuoRow As Long\r\n    currentQuoRow = quoFirstRow\r\n    \r\n        For i = firstRow To lastRow Step 1\r\n        \r\n&#039;        \u5546\u54c1\u30ea\u30b9\u30c8\u306e\u500b\u6570\u304c0\u3088\u308a\u5927\u304d\u3044\u5834\u5408\r\n            If Worksheets(&quot;\u5546\u54c1\u30ea\u30b9\u30c8&quot;).Cells(i, 3).Value &gt; 0 Then\r\n                \r\n&#039;                \u5546\u54c1\u30ea\u30b9\u30c8\u306e\u30bb\u30eb\u306e\u5024\u3092\u898b\u7a4d\u66f8\u306b\u30b3\u30d4\u30fc\r\n                Worksheets(&quot;\u898b\u7a4d\u66f8&quot;).Cells(currentQuoRow, 1) = Worksheets(&quot;\u5546\u54c1\u30ea\u30b9\u30c8&quot;).Cells(i, 1)\r\n                Worksheets(&quot;\u898b\u7a4d\u66f8&quot;).Cells(currentQuoRow, 5) = Worksheets(&quot;\u5546\u54c1\u30ea\u30b9\u30c8&quot;).Cells(i, 2)\r\n                Worksheets(&quot;\u898b\u7a4d\u66f8&quot;).Cells(currentQuoRow, 6) = Worksheets(&quot;\u5546\u54c1\u30ea\u30b9\u30c8&quot;).Cells(i, 3)\r\n            \r\n&#039;            \u6b21\u306e\u5546\u54c1\u306b\u79fb\u52d5\r\n                currentQuoRow = currentQuoRow + 1\r\n            End If\r\n        Next i\r\nEnd Sub\r\n\r\n\r\nSub reset()\r\n    Dim rowCount As Long\r\n    Dim i As Long\r\n    \r\n&#039;    \u884c\u6570\u306e\u30ab\u30a6\u30f3\u30c8\r\n    rowCount = Worksheets(&quot;\u5546\u54c1\u30ea\u30b9\u30c8&quot;).Range(&quot;A2&quot;).End(xlDown).Row\r\n    \r\n&#039;    2\u884c\u76ee\u304b\u3089\u6700\u7d42\u884c\u306eC\u5217\u306e\u30bb\u30eb\u30920\u306b\u3059\u308b\r\n    For i = 2 To rowCount Step 1\r\n        Worksheets(&quot;\u5546\u54c1\u30ea\u30b9\u30c8&quot;).Cells(i, 3) = 0\r\n    Next\r\n    \r\n    Call clearQuotation\r\nEnd Sub\r\n\r\nSub clearQuotation()\r\n&#039;    \u898b\u7a4d\u66f8\u306e\u30ea\u30b9\u30c8\u306e\u9805\u76ee\u3092\u6d88\u53bb\r\n    Worksheets(&quot;\u898b\u7a4d\u66f8&quot;).Range(&quot;A24:F33&quot;) = 0\r\nEnd Sub\r\n\r\n<\/code><\/pre><\/figure>\n<p>reset\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u3067\u5546\u54c1\u30ea\u30b9\u30c8\u306e\u500b\u6570\u3092\u5168\u30660\u306b\u3057\u3066\u3001clearQuotation\u306b\u3066\u898b\u7a4d\u66f8\u306e\u30ea\u30b9\u30c8\u3092\u6d88\u53bb\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u30dc\u30bf\u30f3\u3078\u306e\u5272\u308a\u5f53\u3066<\/h2>\n<p>\u30b7\u30fc\u30c8\u3078\u306e\u30dc\u30bf\u30f3\u306e\u8ffd\u52a0\u306f\u30e1\u30cb\u30e5\u30fc\u306e\u3000\u958b\u767a -> \u633f\u5165 -> \u30dc\u30bf\u30f3\uff08\u30d5\u30a9\u30fc\u30e0\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\uff09\u304b\u3089\u884c\u3048\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/3b14b7b09812ecd5c023e3c1bf051653.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/3b14b7b09812ecd5c023e3c1bf051653-300x194.jpg\" alt=\"\" width=\"300\" height=\"194\" class=\"alignnone size-medium wp-image-166\" srcset=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/3b14b7b09812ecd5c023e3c1bf051653-300x194.jpg 300w, https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/3b14b7b09812ecd5c023e3c1bf051653.jpg 642w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u30dc\u30bf\u30f3\u3092\u9078\u629e\u5f8c\u3001\u30b7\u30fc\u30c8\u4e0a\u3067\u4efb\u610f\u306e\u7b87\u6240\u3067\u5de6\u30af\u30ea\u30c3\u30af\uff08\u30c9\u30e9\u30c3\u30b0\u3067\u5927\u304d\u3055\u8abf\u6574\uff09\u3067\u30dc\u30bf\u30f3\u304c\u4f5c\u308c\u307e\u3059\u3002<br \/>\n\u5272\u308a\u5f53\u3066\u308b\u30de\u30af\u30ed\u306f\u5148\u307b\u3069\u8ffd\u52a0\u3057\u305fThisWorkbook.reset\u3092\u9078\u3093\u3067OK\u3002<\/p>\n<p><a href=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/a94b40eb3fa18e25cab625cd0e84ab8a.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/a94b40eb3fa18e25cab625cd0e84ab8a-297x300.jpg\" alt=\"\" width=\"297\" height=\"300\" class=\"alignnone size-medium wp-image-167\" srcset=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/a94b40eb3fa18e25cab625cd0e84ab8a-297x300.jpg 297w, https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/a94b40eb3fa18e25cab625cd0e84ab8a.jpg 471w\" sizes=\"auto, (max-width: 297px) 100vw, 297px\" \/><\/a><\/p>\n<p>\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3068\u5546\u54c1\u30ea\u30b9\u30c8\u306e\u500b\u6570\u304c\u5168\u30660\u306b\u306a\u308a\u3001\u898b\u7a4d\u66f8\u306e\u30ea\u30b9\u30c8\u306e\u9805\u76ee\u3082\u6d88\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/533b80564c73cfad7fc050c28e605c0f.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/533b80564c73cfad7fc050c28e605c0f-300x157.jpg\" alt=\"\" width=\"300\" height=\"157\" class=\"alignnone size-medium wp-image-168\" srcset=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/533b80564c73cfad7fc050c28e605c0f-300x157.jpg 300w, https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/533b80564c73cfad7fc050c28e605c0f-768x401.jpg 768w, https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/533b80564c73cfad7fc050c28e605c0f.jpg 922w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/541c5cfb7581cf6364cac0cf96378972.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/541c5cfb7581cf6364cac0cf96378972-219x300.jpg\" alt=\"\" width=\"219\" height=\"300\" class=\"alignnone size-medium wp-image-169\" srcset=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/541c5cfb7581cf6364cac0cf96378972-219x300.jpg 219w, https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/541c5cfb7581cf6364cac0cf96378972.jpg 727w\" sizes=\"auto, (max-width: 219px) 100vw, 219px\" \/><\/a><\/p>\n<p>\u4eca\u56de\u306e\u30a8\u30af\u30bb\u30eb\u30d5\u30a1\u30a4\u30eb<br \/>\n<a href=\"https:\/\/jidouka.work\/wp-content\/uploads\/2017\/07\/7c33e07f643a4ae29be0fce3b2a130f8.zip\">\u5546\u54c1\u30ea\u30b9\u30c8_\u898b\u7a4d\u66f8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30a8\u30af\u30bb\u30eb\u306e\u30b7\u30fc\u30c8\u306b\u5165\u529b\u3092\u884c\u306a\u3063\u305f\u5f8c\u306b\u5165\u529b\u5185\u5bb9\u3092\u30af\u30ea\u30a2\u3057\u305f\u3044\u3068\u3044\u3046\u5834\u5408\u306f\u3088\u304f\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002 \u3053\u3053\u3067 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":168,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[],"class_list":["post-164","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-excel","category-vba"],"_links":{"self":[{"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/posts\/164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jidouka.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=164"}],"version-history":[{"count":2,"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/posts\/164\/revisions"}],"predecessor-version":[{"id":172,"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/posts\/164\/revisions\/172"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jidouka.work\/index.php?rest_route=\/wp\/v2\/media\/168"}],"wp:attachment":[{"href":"https:\/\/jidouka.work\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jidouka.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jidouka.work\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}