{"id":16867,"date":"2020-10-29T16:42:42","date_gmt":"2020-10-29T07:42:42","guid":{"rendered":"http:\/\/xn--4gqynm0cew8m.asia\/?p=16867"},"modified":"2020-10-29T16:44:52","modified_gmt":"2020-10-29T07:44:52","slug":"%e3%83%95%e3%82%a9%e3%83%ab%e3%83%80%e6%a7%8b%e9%80%a0%e3%82%92%e4%b8%80%e8%a6%a7%e3%81%ab%e3%81%99%e3%82%8bexcel-vba","status":"publish","type":"post","link":"http:\/\/xn--4gqynm0cew8m.asia\/?p=16867","title":{"rendered":"\u30d5\u30a9\u30eb\u30c0\u69cb\u9020\u3092\u4e00\u89a7\u306b\u3059\u308bExcel VBA"},"content":{"rendered":"\n<p>\u4ed5\u4e8b\u3057\u3066\u3066\u3001\u30d5\u30a9\u30eb\u30c0\u69cb\u9020\u3068\u53ce\u7d0d\u3055\u308c\u3066\u3044\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u4e00\u89a7\u306b\u3057\u305f\u3044\u306a\u3063\u3066\u601d\u3063\u305f\u3053\u3068\u306a\u3044\u3067\u3059\u304b\uff1f<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Excel VBA\u3067\u4f5c\u3063\u3066\u304a\u304d\u307e\u3057\u305f\u3002<\/h1>\n\n\n\n<p>\u3069\u3046\u305e\u3002<br>\u4f7f\u3063\u3066\u304f\u3060\u3055\u3044\u3002<br>\u7de8\u96c6\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u70b9\u306f\u3001\u5909\u6570\u201dPath\u201d\u306e\u5024\u3060\u3051\u3067\u3059\u3002<\/p>\n\n\n\n<p>14\u5e74\u3076\u308a\u306b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u66f8\u3044\u3066\u308b\u306e\u3067\u3001\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u3057\u3066\u304f\u308c\u308b\u4eba\u52df\u96c6\u4e2d\u3067\u3059m(__)m<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Dim numOfDelimiter As Long\n\nSub mainFFs()\n\n   'Declare\n   Dim subFolders As Object\n   Dim Path As String\n   Dim rowP As Long\n   Dim culP As Long\n   Dim numOfSubF As Long\n   Dim buf As String\n\n   'Set values\n\n   Path = \"C:\\Users\\\" '\u3053\u3053\u306b\u4e00\u756a\u4e0a\u306e\u30d5\u30a9\u30eb\u30c0\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u306d\n   rowP = 1\n   culP = 1\n\n   'Path\u306b \\ \u304c\u4f55\u500b\u3042\u308b\u304b\u6570\u3048\u308b\n   numOfDelimiter = UBound(Split(Path, \"\\\"))\n\n   '\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u3060\u3051\u3001\u66f8\u3044\u3066\u3057\u307e\u3046\n   Cells(1, 1) = Path\n   culP = culP + 1\n   buf = Dir(Path &amp;amp; \"\\*.*\")\n   Do While buf &amp;lt;&amp;gt; \"\"\n       Cells(rowP, culP) = buf\n       rowP = rowP + 1\n       buf = Dir()\n   Loop\n\n   Call writeSubFFs(Path, culP, rowP)\n\nEnd Sub\n\nSub writeSubFFs(Path As String, culP As Long, rowP As Long)\n\n   '\u968e\u5c64\u306e\u8abf\u6574\n   Dim curPath As Long '\u6587\u5b57\u30ab\u30a6\u30f3\u30c8\u6570\n   curPath = UBound(Split(Path, \"\\\"))\n\n   If curPath &amp;lt;= numOfDelimiter + 1 Then\n       culP = 3\n   Else\n       culP = culP + 1\n   End If\n\n   '*** Process ****\n\n   '\u2460\u30d5\u30a9\u30eb\u30c0\u53d6\u5f97\n   Set subFolders = CreateObject(\"Scripting.FileSystemObject\").GetFolder(Path).subFolders\n\n   For Each subFolders In subFolders\n\n   '\u2461\u30d5\u30a9\u30eb\u30c0\u8a18\u8f09\n\n       Path = subFolders.Path\n       Cells(rowP, culP) = Path\n\n   '\u2462\u30d5\u30a1\u30a4\u30eb\u53d6\u5f97\n       culP = culP + 1\n       On Error Resume Next\n       buf = Dir(Path &amp;amp; \"\\*.*\")\n   '\u2463\u30d5\u30a1\u30a4\u30eb\u8a18\u8f09\n       Do While buf &amp;lt;&amp;gt; \"\"\n           Cells(rowP, culP) = buf\n           rowP = rowP + 1\n           buf = Dir()\n       Loop\n\n\n       culP = culP - 1\n       rowP = rowP + 1\n\n       Call writeSubFFs(Path, culP, rowP)\n\n   Next subFolders\nEnd Sub\n<\/code><\/pre>\n\n\n\n<p>\u56e0\u307f\u306b\u3001writeSubFFs\u306f\u81ea\u8eab\u3092\u518d\u8d77\u3057\u3066\u307e\u3059\u3002<br>\uff08\u4e0b\u304b\u3089\uff14\u884c\u76ee\u306eCall\u3067\uff09<br>\u7406\u7531\u306f\u3001\u518d\u8d77\u3057\u306a\u3044\u3068Sub\u30d5\u30a9\u30eb\u30c0\uff11\u968e\u5c64\u5206\u3057\u304b\u53d6\u5f97\u3067\u304d\u306a\u304b\u3063\u305f\u305f\u3081\u3002<\/p>\n\n\n\n<p>\u4eca\u5f8c\u306e\u5fdc\u7528\u3068\u3057\u3066\u306f\u3001\u30d1\u30b9\u3092\u30ea\u30f3\u30af\u306b\u3057\u3066\u307f\u305f\u308a\u30012\u500b\u306eHDD\u306e\u5dee\u5206\u306e\u307f\u3092\u540c\u671f\u3059\u308b\u307f\u305f\u3044\u306a\u30d5\u30a1\u30a4\u30eb\u306e\u524d\u6bb5\u306e\u51e6\u7406\u3068\u3057\u3066\u5229\u7528\u3057\u305f\u308a\uff08\u8eca\u8f2a\u518d\u767a\u540d\u3057\u305d\u3046\u306a\u4e88\u611f\uff09\u3001\u66f8\u304d\u51fa\u3059\u5bfe\u8c61\u30d5\u30a1\u30a4\u30eb\u306b\u6761\u4ef6\u3092\u4ed8\u3051\u3066\u3001\u6b32\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u306e\u307f\u8a18\u8f09\u3057\u305f\u308a\u306a\u3069\u3001\u8272\u3005\u3067\u304d\u307e\u3059\u3088\u306d\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f\u70b9\uff1a<br>\u3000C\u30c9\u30e9\u30a4\u30d6\u304b\u3089\u5b9f\u884c\u3059\u308b\u3068\u3001<br>\u3000\u79c1\u306e\u74b0\u5883\u3060\u3068\u3001\u3068\u3093\u3067\u3082\u306a\u3044\u91cf\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u306a\u308a\u305d\u3046\u3067\u3057\u305f\u3002<br>\u3000\uff08\u4ee5\u4e0b\u306f\u300145\u4e07\u30d5\u30a1\u30a4\u30eb\u691c\u51fa\u304f\u3089\u3044\u3067\u51e6\u7406\u3092\u6b62\u3081\u307e\u3057\u305f\u3002\u306e\u56f3\uff09<br>\u3000\u305d\u3053\u307e\u3067\u691c\u51fa\u3057\u305f\u304f\u306a\u3044\u5834\u5408\u306f\u3001\u5bfe\u8c61\u30d5\u30a1\u30a4\u30eb\u3092\u9650\u5b9a\u3059\u308b\u306a\u308a\u3001\u884c\u306e\u30ab\u30a6\u30f3\u30bf\u30fc\u306b\u5236\u9650\u3092\u8a2d\u3051\u308b\u306a\u308a\u3057\u305f\u65b9\u304c\u826f\u3044\u304b\u3082\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/qiita-user-contents.imgix.net\/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F154794%2F09a9707d-185f-6917-b04f-5eef657b3221.png?ixlib=rb-1.2.2&amp;auto=format&amp;gif-q=60&amp;q=75&amp;s=5ff53b064d8e3b758cb574249aceca81\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" src=\"https:\/\/qiita-user-contents.imgix.net\/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F154794%2F09a9707d-185f-6917-b04f-5eef657b3221.png?ixlib=rb-1.2.2&amp;auto=format&amp;gif-q=60&amp;q=75&amp;s=5ff53b064d8e3b758cb574249aceca81\" alt=\"image.png\"\/><\/a><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">\u53c2\u8003\u306b\u3057\u305f\u30b5\u30a4\u30c8<\/h1>\n\n\n\n<p>\u7d50\u5c40\u3053\u308c\u3092\u6539\u7de8\u3057\u305f\u306e\u304c\u4eca\u56de\u306e\u30b3\u30fc\u30c9<br><a href=\"https:\/\/www.moug.net\/tech\/exvba\/0060088.html\" rel=\"noreferrer noopener\" target=\"_blank\">https:\/\/www.moug.net\/tech\/exvba\/0060088.html<\/a><\/p>\n\n\n\n<p>\u3053\u308c\u305d\u306e\u307e\u307e\u5b9f\u88c5\u3057\u305f\u304b\u3063\u305f\u3051\u3069\u3001bas\u30d5\u30a1\u30a4\u30eb\u304c\u3081\u3093\u3069\u304b\u3063\u305f<br><a href=\"https:\/\/www.asahi-net.or.jp\/~ef2o-inue\/vba_o\/sub05_110_080.html\" rel=\"noreferrer noopener\" target=\"_blank\">https:\/\/www.asahi-net.or.jp\/~ef2o-inue\/vba_o\/sub05_110_080.html<\/a><br><a href=\"https:\/\/www.asahi-net.or.jp\/~ef2o-inue\/download\/sub09_020_110.html\" rel=\"noreferrer noopener\" target=\"_blank\">https:\/\/www.asahi-net.or.jp\/~ef2o-inue\/download\/sub09_020_110.html<\/a><\/p>\n\n\n\n<p>SES\u3060\u3068\u3001\u6a29\u9650\u306e\u95a2\u4fc2\u3067\u3055\u308f\u308c\u306a\u3044\u30d5\u30a9\u30eb\u30c0\u304c\u3042\u308b\u306e\u3067\u3001on error resume next\u3067\u98db\u3070\u3059<br><a href=\"http:\/\/officetanaka.net\/excel\/vba\/tips\/tips104.htm\" rel=\"noreferrer noopener\" target=\"_blank\">http:\/\/officetanaka.net\/excel\/vba\/tips\/tips104.htm<\/a><\/p>\n\n\n\n<p>\u4eca\u5f8c\u306e\u5fdc\u7528<br><a rel=\"noreferrer noopener\" href=\"http:\/\/officetanaka.net\/excel\/vba\/tips\/tips95.htm\" target=\"_blank\">http:\/\/officetanaka.net\/excel\/vba\/tips\/tips95.htm<\/a><br><a rel=\"noreferrer noopener\" href=\"http:\/\/blog.jmiri.net\/?p=1763\" target=\"_blank\">http:\/\/blog.jmiri.net\/?p=1763<\/a><\/p>\n\n\n\n<p>\u81ea\u5206\u306eSNS<\/p>\n\n\n\n<p>Qiita<\/p>\n\n\n\n<p><a href=\"https:\/\/qiita.com\/KenichiTakai\/items\/1b386a2f50b20b50bce9\">https:\/\/qiita.com\/KenichiTakai\/items\/1b386a2f50b20b50bce9<\/a><\/p>\n\n\n\n<p>note<\/p>\n\n\n\n<p><a href=\"https:\/\/note.com\/nopota\/n\/n64f3f7768a75\">https:\/\/note.com\/nopota\/n\/n64f3f7768a75<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ed5\u4e8b\u3057\u3066\u3066\u3001\u30d5\u30a9\u30eb\u30c0\u69cb\u9020\u3068\u53ce\u7d0d\u3055\u308c\u3066\u3044\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u4e00\u89a7\u306b\u3057\u305f\u3044\u306a\u3063\u3066\u601d\u3063\u305f\u3053\u3068\u306a\u3044\u3067\u3059\u304b\uff1f Excel VBA\u3067\u4f5c\u3063\u3066\u304a\u304d\u307e\u3057\u305f\u3002 \u3069\u3046\u305e\u3002\u4f7f\u3063\u3066\u304f\u3060\u3055\u3044\u3002\u7de8\u96c6\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u70b9\u306f\u3001\u5909\u6570\u201dPath\u201d\u306e\u5024\u3060\u3051\u3067\u3059\u3002 14\u5e74\u3076\u308a\u306b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0[&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[37],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p53nwf-4o3","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/xn--4gqynm0cew8m.asia\/index.php?rest_route=\/wp\/v2\/posts\/16867"}],"collection":[{"href":"http:\/\/xn--4gqynm0cew8m.asia\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xn--4gqynm0cew8m.asia\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xn--4gqynm0cew8m.asia\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xn--4gqynm0cew8m.asia\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16867"}],"version-history":[{"count":2,"href":"http:\/\/xn--4gqynm0cew8m.asia\/index.php?rest_route=\/wp\/v2\/posts\/16867\/revisions"}],"predecessor-version":[{"id":16873,"href":"http:\/\/xn--4gqynm0cew8m.asia\/index.php?rest_route=\/wp\/v2\/posts\/16867\/revisions\/16873"}],"wp:attachment":[{"href":"http:\/\/xn--4gqynm0cew8m.asia\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xn--4gqynm0cew8m.asia\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16867"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xn--4gqynm0cew8m.asia\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}