{"id":5960,"date":"2023-11-08T21:49:08","date_gmt":"2023-11-08T12:49:08","guid":{"rendered":"https:\/\/okamurax.com\/?p=5960"},"modified":"2023-11-08T21:51:28","modified_gmt":"2023-11-08T12:51:28","slug":"vba-%e9%81%b8%e6%8a%9e%e3%81%97%e3%81%9f%e8%a4%87%e6%95%b0%e3%82%b7%e3%83%bc%e3%83%88%e3%81%8b%e3%82%89%e3%82%b3%e3%83%94%e3%83%bc","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=5960","title":{"rendered":"VBA \u9078\u629e\u3057\u305f\u8907\u6570\u30b7\u30fc\u30c8\u304b\u3089\u30b3\u30d4\u30fc"},"content":{"rendered":"<p>\u8907\u6570\u306e\u30b7\u30fc\u30c8\u3092\u9078\u629e\u3057\u3066\u3044\u308b\u72b6\u614b\u306a\u306e\u3067\u3001\u30ea\u30dc\u30f3(\u30e1\u30cb\u30e5\u30fc\u30d0\u30fc)\u306b\u30dc\u30bf\u30f3\u3092\u8ffd\u52a0<\/p>\n<pre class=\"lang:vb decode:true\">Sub test()\r\n\r\nApplication.CommandBars(\"worksheet menu bar\").Reset\r\n\r\nEnd Sub\r\n\r\nSub auto_open()\r\n\r\nOn Error Resume Next\r\n\r\ncaption = \"\u9078\u629e\u4e00\u89a7\"\r\n\r\nFor x = 1 To 3\r\n Application.CommandBars(\"worksheet menu bar\").Controls(caption).Delete\r\nNext\r\n\r\nWith Application.CommandBars(\"worksheet menu bar\").Controls.Add(Type:=msoControlButton)\r\n.Style = msoButtonCaption\r\n.caption = caption\r\n.OnAction = \"main\"\r\nEnd With\r\n\r\nEnd Sub\r\n\r\nSub auto_close()\r\n\r\ncaption = \"\u9078\u629e\u4e00\u89a7\"\r\n\r\nOn Error Resume Next\r\n\r\nFor x = 1 To 3\r\n Application.CommandBars(\"worksheet menu bar\").Controls(caption).Delete\r\nNext\r\n\r\nEnd Sub\r\n\r\nSub Initialize()\r\n\r\nApplication.ScreenUpdating = False\r\nApplication.EnableEvents = False\r\nApplication.DisplayAlerts = False\r\n    \r\nEnd Sub\r\n\r\nSub Finalize()\r\n\r\nApplication.DisplayAlerts = True\r\nApplication.EnableEvents = True\r\nApplication.ScreenUpdating = True\r\n    \r\nEnd Sub\r\n\r\nSub main()\r\n\r\nInitialize\r\n\r\ncaption = \"\u9078\u629e\u4e00\u89a7\"\r\n\r\nexists = False\r\nFor Each w In Sheets\r\n  If w.Name = caption Then\r\n    exists = True\r\n    Exit For\r\n  End If\r\nNext w\r\n\r\nIf exists = False Then\r\n  MsgBox caption &amp; \"\u30b7\u30fc\u30c8\u304c\u5b58\u5728\u3057\u307e\u305b\u3093\u3002\"\r\n  Exit Sub\r\nEnd If\r\n\r\nSheets(caption).Rows(\"1:1000\").Delete\r\n\r\nr = 1\r\nFor Each w In ActiveWindow.SelectedSheets\r\n  If w.Name &lt;&gt; caption Then\r\n  \r\n    w.Range(\"A2:AD22\").Copy\r\n    Sheets(caption).Cells(r, 1).PasteSpecial xlPasteValues\r\n    w.Range(\"A2:AD22\").Copy\r\n    Sheets(caption).Cells(r, 1).PasteSpecial xlPasteFormats\r\n    \r\n  End If\r\nr = r + 23\r\nNext w\r\n\r\nSheets(caption).Select\r\nApplication.CutCopyMode = False\r\n\r\nFinalize\r\n\r\nEnd Sub<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8907\u6570\u306e\u30b7\u30fc\u30c8\u3092\u9078\u629e\u3057\u3066\u3044\u308b\u72b6\u614b\u306a\u306e\u3067\u3001\u30ea\u30dc\u30f3(\u30e1\u30cb\u30e5\u30fc\u30d0\u30fc)\u306b\u30dc\u30bf\u30f3\u3092\u8ffd\u52a0 Sub test() Application.CommandBars(&#8220;worksheet menu bar&#8221;).Reset End Sub S &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=5960\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;VBA \u9078\u629e\u3057\u305f\u8907\u6570\u30b7\u30fc\u30c8\u304b\u3089\u30b3\u30d4\u30fc&#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-5960","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\/5960","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=5960"}],"version-history":[{"count":3,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/5960\/revisions"}],"predecessor-version":[{"id":5963,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/5960\/revisions\/5963"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}