{"id":24365,"date":"2026-04-30T11:14:41","date_gmt":"2026-04-30T03:14:41","guid":{"rendered":"https:\/\/blog.iyatt.com\/?p=24365"},"modified":"2026-04-30T11:14:41","modified_gmt":"2026-04-30T03:14:41","slug":"excel-%e6%89%b9%e9%87%8f%e9%80%90%e5%88%97%e5%90%88%e5%b9%b6-vba-%e5%ae%8f","status":"publish","type":"post","link":"https:\/\/blog.iyatt.com\/?p=24365","title":{"rendered":"Excel \u6279\u91cf\u9010\u5217\u5408\u5e76 VBA \u5b8f"},"content":{"rendered":"<p>2026\/4\/30<br \/>\nExcel \u53ea\u63d0\u4f9b\u4e86\u6279\u91cf\u9010\u884c\u5408\u5e76\uff08\u8de8\u8d8a\u5408\u5e76\uff09\uff0c\u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u8db3\u591f\u4f7f\u7528\uff0c\u4f46\u662f\u96be\u514d\u9047\u5230\u9700\u8981\u6279\u91cf\u9010\u5217\u5408\u5e76\u7684\uff0c\u624b\u52a8\u64cd\u4f5c\u592a\u9ebb\u70e6\u3002<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2026\/04\/image-1777518341001.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 232px; --smush-placeholder-aspect-ratio: 232\/218;\" \/><\/p>\n<p>\u5728\u8981\u64cd\u4f5c\u7684\u8868\u683c\u5904\u4e8e\u6253\u5f00\u72b6\u6001\u4e0b\uff0c\u6309 <code class=\"kb-btn\">Alt<\/code>+<code class=\"kb-btn\">F11<\/code> \u6253\u5f00 VBA \u7f16\u8f91\u5668\uff0c\u63d2\u5165\u6a21\u5757<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2026\/04\/image-1777518611368.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 333px; --smush-placeholder-aspect-ratio: 333\/184;\" \/><\/p>\n<p>\u5c06\u4e0b\u9762\u4ee3\u7801\u7c98\u8d34\u8fdb\u53bb\uff08\u7531 Google Gemini \u751f\u6210\uff09<\/p>\n<pre><code class=\"language-bash\">Sub BatchMergeByColumnsWithPicker()\n    Dim selectedRange As Range\n    Dim col As Range\n\n    &#039; \u5f39\u51fa\u9009\u62e9\u6846\uff0cType:=8 \u8868\u793a\u8981\u6c42\u7528\u6237\u9009\u62e9\u4e00\u4e2a\u5355\u5143\u683c\u533a\u57df (Range)\n    &#039; On Error Resume Next \u7528\u4e8e\u5904\u7406\u7528\u6237\u70b9\u51fb\u201c\u53d6\u6d88\u201d\u7684\u60c5\u51b5\n    On Error Resume Next\n    Set selectedRange = Application.InputBox( _\n        Prompt:=&quot;\u8bf7\u7528\u9f20\u6807\u62d6\u9009\u4f60\u60f3\u8981\u3010\u6309\u5217\u5408\u5e76\u3011\u7684\u533a\u57df\uff1a&quot;, _\n        Title:=&quot;\u9009\u62e9\u5408\u5e76\u533a\u57df&quot;, _\n        Type:=8)\n    On Error GoTo 0\n\n    &#039; \u68c0\u67e5\u7528\u6237\u662f\u5426\u70b9\u51fb\u4e86\u53d6\u6d88\n    If selectedRange Is Nothing Then\n        Exit Sub\n    End If\n\n    &#039; \u6027\u80fd\u4f18\u5316\uff1a\u5173\u95ed\u5c4f\u5e55\u95ea\u70c1\u548c\u8986\u76d6\u8b66\u544a\n    Application.ScreenUpdating = False\n    Application.DisplayAlerts = False\n\n    &#039; \u6267\u884c\u6309\u5217\u5408\u5e76\u903b\u8f91\n    For Each col In selectedRange.Columns\n        col.Merge\n        col.HorizontalAlignment = xlCenter\n        col.VerticalAlignment = xlCenter\n    Next col\n\n    &#039; \u6062\u590d\u8bbe\u7f6e\n    Application.DisplayAlerts = True\n    Application.ScreenUpdating = True\n\n    MsgBox &quot;\u5df2\u5b8c\u6210\u5bf9\u9009\u5b9a\u5217\u7684\u6279\u91cf\u5408\u5e76\uff01&quot;, vbInformation\nEnd Sub<\/code><\/pre>\n<p>\u56de\u5230\u8981\u64cd\u4f5c\u7684\u8868\u683c\uff0c\u6309<code class=\"kb-btn\">Alt<\/code>+<code class=\"kb-btn\">F8<\/code>\u6253\u5f00\u8fd0\u884c\u5b8f\u5bf9\u8bdd\u6846\uff0c\u9009\u4e2d<strong>BatchMergeByColumnsWithPicker<\/strong>\u5b8f\uff0c\u70b9\u51fb<strong>\u6267\u884c<\/strong><br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2026\/04\/image-1777518706906.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 460px; --smush-placeholder-aspect-ratio: 460\/482;\" \/><\/p>\n<p>\u9009\u62e9\u5408\u5e76\u533a\u57df<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2026\/04\/image-1777518757880.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 747px; --smush-placeholder-aspect-ratio: 747\/482;\" \/><\/p>\n<p>\u70b9\u51fb<strong>\u786e\u5b9a<\/strong>\u540e\u5b8c\u6210\u5408\u5e76<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2026\/04\/image-1777518829575.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 810px; --smush-placeholder-aspect-ratio: 810\/522;\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>2026\/4\/30 Excel \u53ea\u63d0\u4f9b\u4e86\u6279\u91cf\u9010\u884c\u5408\u5e76\uff08\u8de8\u8d8a\u5408\u5e76\uff09\uff0c\u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u8db3\u591f\u4f7f\u7528\uff0c\u4f46\u662f\u96be\u514d\u9047\u5230\u9700\u8981\u6279\u91cf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"zakra_page_container_layout":"customizer","zakra_page_sidebar_layout":"customizer","zakra_remove_content_margin":false,"zakra_sidebar":"customizer","zakra_transparent_header":"customizer","zakra_logo":0,"zakra_main_header_style":"default","zakra_menu_item_color":"","zakra_menu_item_hover_color":null,"zakra_menu_item_active_color":null,"zakra_menu_active_style":"","zakra_page_header":true,"_lmt_disableupdate":"no","_lmt_disable":"no","footnotes":""},"categories":[1,649,648],"tags":[1750,1964,2095,1965,1855,2096,2094],"class_list":["post-24365","post","type-post","status-publish","format-standard","hentry","category-all","category-excel","category-office","tag-excel","tag-vba","tag-2095","tag-1965","tag-1855","tag-2096","tag-2094"],"modified_by":"IYATT-yx","_links":{"self":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/24365","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=24365"}],"version-history":[{"count":1,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/24365\/revisions"}],"predecessor-version":[{"id":24372,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/24365\/revisions\/24372"}],"wp:attachment":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=24365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=24365"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=24365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}