{"id":10013,"date":"2018-02-09T10:45:02","date_gmt":"2018-02-09T01:45:02","guid":{"rendered":"https:\/\/www.ka-net.org\/blog\/?p=10013"},"modified":"2018-02-09T11:05:33","modified_gmt":"2018-02-09T02:05:33","slug":"%e6%8c%87%e5%ae%9a%e3%81%97%e3%81%9f%e3%83%95%e3%82%a9%e3%83%ab%e3%83%80%e5%86%85%e3%81%ab%e3%81%82%e3%82%8bexcel%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%82%92%e4%b8%80%e3%81%a4%e3%81%ab%e3%81%be","status":"publish","type":"post","link":"https:\/\/www.ka-net.org\/blog\/?p=10013","title":{"rendered":"\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u5185\u306b\u3042\u308bExcel\u30d5\u30a1\u30a4\u30eb\u3092\u4e00\u3064\u306b\u307e\u3068\u3081\u308bVBA\u30de\u30af\u30ed"},"content":{"rendered":"<p>\u8907\u6570\u3042\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u4e00\u3064\u306b\u307e\u3068\u3081\u308b\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u826f\u3044\u304b\uff1f\u3068\u3044\u3046\u8cea\u554f\u3092\u3044\u305f\u3060\u3044\u305f\u306e\u3067\u3001\u7c21\u5358\u306a\u30de\u30af\u30ed\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u4e0b\u8a18\u306e\u901a\u308a\u3001\u305d\u308c\u305e\u308c\u306e\u51e6\u7406\u306e\u610f\u5473\u306f\u30b3\u30e1\u30f3\u30c8\u3067\u8a18\u5165\u3057\u3066\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">Option Explicit\r\n\r\nPublic Sub Sample()\r\n  Dim bkWork As Workbook '\u4f5c\u696d\u7528\u30ef\u30fc\u30af\u30d6\u30c3\u30af\r\n  Dim bkSrc As Workbook '\u30b3\u30d4\u30fc\u5143\u30ef\u30fc\u30af\u30d6\u30c3\u30af\r\n  Dim shtIni As Worksheet '\u521d\u671f\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\r\n  Dim folderPath As String '\u51e6\u7406\u5bfe\u8c61\u306e\u30d5\u30a9\u30eb\u30c0\u30d1\u30b9\r\n  Dim tmpSinw As Long 'SheetsInNewWorkbook\u4e00\u6b21\u8a18\u61b6\u7528\r\n  Dim tmpDa As Boolean 'DisplayAlerts\u4e00\u6b21\u8a18\u61b6\u7528\r\n  Dim itm As Object\r\n  \r\n  'Excel\u30d5\u30a1\u30a4\u30eb\u304c\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u30d5\u30a9\u30eb\u30c0\u3092\u9078\u629e\r\n  With Application.FileDialog(msoFileDialogFolderPicker)\r\n    .AllowMultiSelect = False '\u8907\u6570\u9078\u629e\u3057\u306a\u3044\r\n    .Title = &quot;Excel\u30d5\u30a1\u30a4\u30eb\u304c\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u30d5\u30a9\u30eb\u30c0\u3092\u9078\u629e&quot;\r\n    If .Show = True Then\r\n      folderPath = .SelectedItems(1) '\u9078\u629e\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u306e\u30d1\u30b9\u3092\u5909\u6570\u306b\u683c\u7d0d\r\n    Else\r\n      Exit Sub '\u30d5\u30a9\u30eb\u30c0\u304c\u9078\u629e\u3055\u308c\u306a\u304b\u3063\u305f\u5834\u5408\u306f\u51e6\u7406\u7d42\u4e86\r\n    End If\r\n  End With\r\n  \r\n  '\u4f5c\u696d\u7528\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u306e\u4f5c\u6210\r\n  With Application\r\n    tmpSinw = .SheetsInNewWorkbook '\u65b0\u898f\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u306b\u81ea\u52d5\u7684\u306b\u633f\u5165\u3055\u308c\u308b\u30b7\u30fc\u30c8\u6570\u3092\u8a18\u61b6\r\n    .SheetsInNewWorkbook = 1\r\n    Set bkWork = .Workbooks.Add '\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u8ffd\u52a0\r\n    Set shtIni = bkWork.Sheets(1) '\u6700\u521d\u306e\u7a7a\u767d\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u3092\u8a18\u61b6\r\n    .SheetsInNewWorkbook = tmpSinw '\u65b0\u898f\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u306b\u81ea\u52d5\u7684\u306b\u633f\u5165\u3055\u308c\u308b\u30b7\u30fc\u30c8\u6570\u3092\u5143\u306b\u623b\u3059\r\n  End With\r\n  \r\n  '\u30d5\u30a1\u30a4\u30eb\u306e\u51e6\u7406\u306bFileSystemObject\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u5229\u7528\r\n  With CreateObject(&quot;Scripting.FileSystemObject&quot;)\r\n    '\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u9806\u756a\u306b\u51e6\u7406\r\n    For Each itm In .GetFolder(folderPath).Files\r\n      '\u51e6\u7406\u5bfe\u8c61\u3068\u306a\u308b\u30d5\u30a1\u30a4\u30eb\u306e\u62e1\u5f35\u5b50\u3092\u6307\u5b9a\r\n      Select Case LCase(.GetExtensionName(itm.Path))\r\n        Case &quot;xls&quot;, &quot;xlsx&quot;, &quot;xlsm&quot;, &quot;csv&quot;\r\n          Set bkSrc = Application.Workbooks.Open(itm.Path) '\u30b3\u30d4\u30fc\u5143\u306e\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u3092\u958b\u304f\r\n          With bkWork\r\n            '\u5168\u30b7\u30fc\u30c8\u3092\u4f5c\u696d\u7528\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u306b\u30b3\u30d4\u30fc\r\n            '\u203b\u540c\u540d\u306e\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u304c\u3042\u308b\u5834\u5408\u306f\u81ea\u52d5\u7684\u306b\u30b7\u30fc\u30c8\u540d\u304c\u5909\u66f4\u3055\u308c\u308b\r\n            bkSrc.Sheets.Copy After:=.Sheets(.Sheets.Count)\r\n          End With\r\n          bkSrc.Close SaveChanges:=False '\u30b3\u30d4\u30fc\u5143\u306e\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u3092\u5909\u66f4\u305b\u305a\u306b\u9589\u3058\u308b\r\n      End Select\r\n    Next\r\n  End With\r\n  \r\n  '\u6700\u521d\u306e\u7a7a\u767d\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u3092\u524a\u9664\r\n  If bkWork.Sheets.Count &gt; 1 Then\r\n    With Application\r\n      tmpDa = .DisplayAlerts '\u8b66\u544a\u306e\u8868\u793a\u72b6\u614b\u3092\u8a18\u61b6\r\n      .DisplayAlerts = False '\u8b66\u544a\u306e\u8868\u793a\u3092\u7121\u52b9\u306b\u8a2d\u5b9a\r\n      shtIni.Delete '\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u524a\u9664\r\n      .DisplayAlerts = tmpDa '\u8b66\u544a\u306e\u8868\u793a\u72b6\u614b\u3092\u5143\u306b\u623b\u3059\r\n    End With\r\n  End If\r\nEnd Sub<\/pre>\n<p>\u30b3\u30fc\u30c9\u306e\u8cbc\u308a\u4ed8\u3051\u65b9\u3084\u5b9f\u884c\u65b9\u6cd5\u304c\u5206\u304b\u3089\u306a\u3044\u5834\u5408\u306f\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u5165\u9580\u8005\u5411\u3051\u306e\u30b5\u30a4\u30c8\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li>Office TANAKA &#8211; VBA\u306f\u3058\u3081\u306e\u4e00\u6b69<\/li>\n<li style=\"list-style-type:none;\"><a href=\"http:\/\/officetanaka.net\/excel\/vba\/first\/\" target=\"_blank\" title=\"Office TANAKA - VBA\u306f\u3058\u3081\u306e\u4e00\u6b69\">http:\/\/officetanaka.net\/excel\/vba\/first\/<\/a><\/li>\n<\/ul>\n<p>\u521d\u3081\u3066VBA\u306b\u89e6\u308c\u308b\u65b9\u306f\u3001\u4e0b\u8a18\u8a18\u4e8b\u3067\u7d39\u4ecb\u3057\u3066\u3044\u308b\u3088\u3046\u306a\u521d\u5b66\u8005\u5411\u3051\u306e\u66f8\u7c4d\u3092\u53c2\u8003\u306b\u3059\u308b\u3053\u3068\u3092\u304a\u85a6\u3081\u3044\u305f\u3057\u307e\u3059\u3002<\/p>\n<div class=\"cardlink\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=9896\"><div class=\"cardlink_thumbnail\"><img src='https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-ExcelVBA-120x120.png' alt='\u300c\u3044\u3061\u3070\u3093\u3084\u3055\u3057\u3044Excel VBA\u306e\u6559\u672c\u300d\u30ec\u30d3\u30e5\u30fc' width=120 height=120 \/><\/a><\/div><div class=\"cardlink_content\"><span class=\"timestamp\">2018.01.20<\/span><div class=\"cardlink_title\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=9896\">\u300c\u3044\u3061\u3070\u3093\u3084\u3055\u3057\u3044Excel VBA\u306e\u6559\u672c\u300d\u30ec\u30d3\u30e5\u30fc <\/a><\/div><div class=\"cardlink_excerpt\">VBA\u306e\u5b66\u7fd2\u8005\u3067\u3042\u308c\u3070\u4e00\u5ea6\u306f\u898b\u305f\u3053\u3068\u304c\u3042\u308b\u3067\u3042\u308d\u3046\u3001\u8d85\u6709\u540d\u8001\u8217\u30b5\u30a4\u30c8\u300c\u30a4\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u30fc\u306e\u30cd\u30bf\u5e33\u300d\u306e\u4f0a\u85e4\u3055\u3093\u304c\u57f7\u7b46\u3055\u308c\u305fVBA\u89e3\u8aac\u672c\u3001\u300c\u3044\u3061\u3070\u3093\u3084\u3055\u3057\u3044Excel VBA\u306e\u6559\u672c\u300d\u304c\u3064\u3044\u306b\u767a\u58f2\u958b\u59cb\u3055\u308c\u307e\u3057\u305f\u3002\r\n\r\n\r\n\r\n\u6982\u8981\r\n\r\n\u672c\u66f8\u306e\u76ee\u6b21\u306f\u4e0b\u8a18\u306e\u901a\u308a\u3067\u3001\u30b5...<\/div><\/div><div class=\"cardlink_footer\"><\/div><\/div>\n<div class=\"cardlink\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=3228\"><div class=\"cardlink_thumbnail\"><img src='https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-Excel-120x120.png' alt='\u300c\u30b9\u30c8\u30fc\u30ea\u30fc\u3067\u5b66\u3076 Excel VBA\u3068\u696d\u52d9\u6539\u5584\u306e\u30dd\u30a4\u30f3\u30c8\u304c\u308f\u304b\u308b\u672c\u300d\u306e\u898b\u672c\u8a8c\u3092\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002' width=120 height=120 \/><\/a><\/div><div class=\"cardlink_content\"><span class=\"timestamp\">2013.07.11<\/span><div class=\"cardlink_title\"><a href=\"https:\/\/www.ka-net.org\/blog\/?p=3228\">\u300c\u30b9\u30c8\u30fc\u30ea\u30fc\u3067\u5b66\u3076 Excel VBA\u3068\u696d\u52d9\u6539\u5584\u306e\u30dd\u30a4\u30f3\u30c8\u304c\u308f\u304b\u308b\u672c\u300d\u306e\u898b\u672c\u8a8c\u3092\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002 <\/a><\/div><div class=\"cardlink_excerpt\">\u300cCell_\u96c0\u300d\u3067\u6709\u540d\u306aExcel MVP\u306e\u6b66\u85e4\u3055\u3093\u306b\u8457\u66f8\u3067\u3042\u308b\u300c\u30b9\u30c8\u30fc\u30ea\u30fc\u3067\u5b66\u3076 Excel VBA\u3068\u696d\u52d9\u6539\u5584\u306e\u30dd\u30a4\u30f3\u30c8\u304c\u308f\u304b\u308b\u672c\u300d\u306e\u898b\u672c\u8a8c\u3092\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002\r\n\u6b66\u85e4\u3055\u3093\u3001\u30aa\u30c7\u30c3\u30bb\u30a4 \u30b3\u30df\u30e5\u30cb\u30b1\u30fc\u30b7\u30e7\u30f3\u30ba\u3055\u3093\u3001\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff01\r\n\r\n\r\n    \r\n\r...<\/div><\/div><div class=\"cardlink_footer\"><\/div><\/div>\n<p>\u307e\u305f\u3001\u4eca\u56de\u306f\u30de\u30af\u30ed\u3067\u306e\u51e6\u7406\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u304c\u3001\u30d5\u30a1\u30a4\u30eb\u6570\u304c\u5c11\u306a\u3044\u5834\u5408\u306f\u3001\u300c<a href=\"https:\/\/azby.fmworld.net\/usage\/windows_tips\/20050909\/\" title=\"\uff3b\u30a8\u30af\u30bb\u30eb\uff3d\u7570\u306a\u308b\u30d5\u30a1\u30a4\u30eb\uff08\u30d6\u30c3\u30af\uff09\u306b\u30b7\u30fc\u30c8\u3092\u79fb\u52d5\u30fb\u30b3\u30d4\u30fc\u3057\u305f\u3044 - FMV\u30b5\u30dd\u30fc\u30c8 : \u5bcc\u58eb\u901a\" target=\"_blank\">\uff3b\u30a8\u30af\u30bb\u30eb\uff3d\u7570\u306a\u308b\u30d5\u30a1\u30a4\u30eb\uff08\u30d6\u30c3\u30af\uff09\u306b\u30b7\u30fc\u30c8\u3092\u79fb\u52d5\u30fb\u30b3\u30d4\u30fc\u3057\u305f\u3044<\/a>\u300d\u306b\u3042\u308b\u65b9\u6cd5\u3067\u3001\u624b\u52d5\u3067\u51e6\u7406\u3057\u3066\u3082\u826f\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<div id=\"single_banner_area2\" class=\"clearfix one_banner\">\n<div class=\"single_banner single_banner_left\">\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<!-- \u8a18\u4e8b\u4e2d(\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u5e83\u544a\u30e6\u30cb\u30c3\u30c8) -->\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block\"\r\n     data-ad-client=\"ca-pub-7306936664602087\"\r\n     data-ad-slot=\"5429724765\"\r\n     data-ad-format=\"auto\"\r\n     data-full-width-responsive=\"true\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\n<\/div>\n<div class=\"single_banner single_banner_right\">\n<a href=\"\" target=\"_blank\"><img decoding=\"async\" src=\"\" alt=\"\" title=\"\" \/><\/a>\n<\/div>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"\u8907\u6570\u3042\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u4e00\u3064\u306b\u307e\u3068\u3081\u308b\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u826f\u3044\u304b\uff1f\u3068\u3044\u3046\u8cea\u554f\u3092\u3044\u305f\u3060\u3044\u305f\u306e\u3067\u3001\u7c21\u5358\u306a\u30de\u30af\u30ed\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002 \u4e0b\u8a18\u306e\u901a\u308a\u3001\u305d\u308c\u305e\u308c\u306e\u51e6\u7406\u306e\u610f\u5473\u306f\u30b3\u30e1\u30f3\u30c8\u3067\u8a18\u5165\u3057\u3066\u3042\u308a\u307e\u3059\u3002 Option Explicit Publi [&hellip;]","protected":false},"author":1,"featured_media":7112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"[\u6307\u5b9a\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u5185\u306b\u3042\u308bExcel\u30d5\u30a1\u30a4\u30eb\u3092\u4e00\u3064\u306b\u307e\u3068\u3081\u308bVBA\u30de\u30af\u30ed]","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,48],"tags":[],"class_list":["post-10013","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office","category-excel-office"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.ka-net.org\/blog\/wp-content\/uploads\/eyecatch-ExcelVBA.png","jetpack_shortlink":"https:\/\/wp.me\/p4UZZr-2Bv","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10013"}],"version-history":[{"count":2,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10013\/revisions"}],"predecessor-version":[{"id":10015,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10013\/revisions\/10015"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/7112"}],"wp:attachment":[{"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ka-net.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}