{"id":4764,"date":"2018-10-04T23:10:04","date_gmt":"2018-10-04T14:10:04","guid":{"rendered":"https:\/\/elleneast.com\/?p=4764"},"modified":"2018-10-17T21:43:26","modified_gmt":"2018-10-17T12:43:26","slug":"%e3%80%90excel-vba%e3%80%91%e7%89%b9%e5%ae%9a%e3%81%ae%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88%e3%81%ae%e3%82%bb%e3%83%ab%e4%bd%8d%e7%bd%ae%e3%82%92%e5%9f%ba%e6%ba%96%e3%81%ab%e3%81%97%e3%81%a6%e8%a8%88","status":"publish","type":"post","link":"https:\/\/elleneast.com\/?p=4764","title":{"rendered":"\u3010Excel VBA\u3011\u884c\u306e\u4f4d\u7f6e\u304c\u5909\u308f\u308b\u7279\u5b9a\u306e\u30bb\u30eb\u3092\u57fa\u6e96\u306b\u3057\u3066\u8a08\u7b97\u7bc4\u56f2\u3092\u6c42\u3081\u308b"},"content":{"rendered":"<p>\u77e5\u308a\u5408\u3044\u306e\u65b9\u304b\u3089 Excel VBA \u306b\u3064\u3044\u3066\u8cea\u554f\u3092\u3044\u305f\u3060\u3044\u305f\u306e\u3067\u3001\u30d6\u30ed\u30b0\u30cd\u30bf\u306b\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u76ee\u6b21<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/elleneast.com\/?p=4764\/#%E8%B3%AA%E5%95%8F%E5%86%85%E5%AE%B9\" >\u8cea\u554f\u5185\u5bb9<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/elleneast.com\/?p=4764\/#%E7%89%B9%E5%AE%9A%E3%81%AE%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%81%AE%E8%A1%8C%E7%95%AA%E5%8F%B7%E3%82%92%E8%AA%BF%E3%81%B9%E3%81%A6%E3%80%81%E7%B8%A6%E6%96%B9%E5%90%91%E3%81%AE%E8%A8%88%E7%AE%97%E3%82%92%E3%81%99%E3%82%8B\" >\u7279\u5b9a\u306e\u30c6\u30ad\u30b9\u30c8\u306e\u884c\u756a\u53f7\u3092\u8abf\u3079\u3066\u3001\u7e26\u65b9\u5411\u306e\u8a08\u7b97\u3092\u3059\u308b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/elleneast.com\/?p=4764\/#%E7%89%B9%E5%AE%9A%E3%81%AE%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%81%AE%E8%A1%8C%E7%95%AA%E5%8F%B7%E3%82%92%E8%AA%BF%E3%81%B9%E3%81%A6%E3%80%81%E6%A8%AA%E6%96%B9%E5%90%91%E3%81%AE%E8%A8%88%E7%AE%97%E3%82%92%E3%81%99%E3%82%8B\" >\u7279\u5b9a\u306e\u30c6\u30ad\u30b9\u30c8\u306e\u884c\u756a\u53f7\u3092\u8abf\u3079\u3066\u3001\u6a2a\u65b9\u5411\u306e\u8a08\u7b97\u3092\u3059\u308b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/elleneast.com\/?p=4764\/#%E6%A9%9F%E8%83%BD%E3%82%92%E3%82%B5%E3%83%96%E3%83%AB%E3%83%BC%E3%83%81%E3%83%B3%E3%81%AB%E5%88%86%E3%81%91%E3%82%8B\" >\u6a5f\u80fd\u3092\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u306b\u5206\u3051\u308b<\/a><\/li><\/ul><\/nav><\/div>\n<h2 id=\"i-0\"><span class=\"ez-toc-section\" id=\"%E8%B3%AA%E5%95%8F%E5%86%85%E5%AE%B9\"><\/span>\u8cea\u554f\u5185\u5bb9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u8cea\u554f\u5185\u5bb9\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<div class=\"sng-box box15\">\n<p>A \u5217\u306b\u300c\u5408\u8a08\u300d\u3068\u51fa\u3066\u304d\u305f\u3089\u3001\u305d\u306e\u884c\u3068\u540c\u3058 B \u5217\u306e\u30bb\u30eb\u306b B \u5217\u306e\u5408\u8a08\u5024\u3092\u5165\u308c\u305f\u3044\uff08C \u5217\u3001D \u5217\u30fb\u30fb\u30fb\u3082\u540c\u69d8\u306b\u3057\u305f\u3044\uff09\u3002<br \/>\n\u3067\u3082\u300c\u5408\u8a08\u300d\u306e\u884c\u304c\u6bce\u56de\u9055\u3046\u306e\u3067\u3001\u3069\u306e\u3088\u3046\u306b\u3059\u308c\u3070\u3044\u3044\u306e\u304b\u5206\u304b\u3089\u306a\u3044\u3002<\/p>\n<\/div>\n<p>\u305f\u3068\u3048\u3070\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30c7\u30fc\u30bf\u306e\u3053\u3068\u3067\u3059\u306d\u3002\u4e0b\u8a18\u306e\u8868\u306f\u3001\u3042\u308b\u30b3\u30f3\u30d3\u30cb\u306e\uff11\u5e97\u8217\u3092\u8a2a\u308c\u305f\u5ba2\u3054\u3068\u306b\u4f55\u3092\u4f55\u70b9\u8cb7\u3063\u305f\u304b\u3068\u3044\u3046\u30c7\u30fc\u30bf\u3092\u307e\u3068\u3081\u305f\u3082\u306e\uff08\u3068\u3044\u3046\u60f3\u5b9a\uff09\u3067\u3059\u3002<\/p>\n<p><a href=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181004_5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4792 bigshadow\" src=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181004_5.png\" alt=\"\" width=\"540\" height=\"241\" srcset=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181004_5.png 540w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181004_5-300x134.png 300w\" sizes=\"auto, (max-width: 540px) 100vw, 540px\"><\/a><\/p>\n<p>\u3053\u306e\u3088\u3046\u306a\u30c7\u30fc\u30bf\u304c\uff12\uff10\u4ee5\u4e0a\u306e\u652f\u5e97\u304b\u3089\u6bce\u65e5\u3001\u30b3\u30f3\u30d3\u30cb\u306e\u672c\u90e8\u9577\u306e\u3068\u3053\u308d\u306b\u9001\u3089\u308c\u3066\u304d\u3066\u3001\u54c1\u7269\u306e\u7a2e\u985e\u3054\u3068\u306e\u5408\u8a08\u5024\u3092\u672c\u90e8\u9577\u304c\u8a08\u7b97\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>\u672c\u90e8\u9577\u306f VBA \u3067\u5408\u8a08\u5024\u3092\u6c42\u3081\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308d\u3046\u3068\u3057\u307e\u3057\u305f\u304c\u3001\u652f\u5e97\u3054\u3068\u306b\u5ba2\u306e\u6570\uff08\u884c\u6570\uff09\u306f\u9055\u3044\u307e\u3059\u3057\u3001\u540c\u3058\u652f\u5e97\u3067\u3082\u5ba2\u6570\u306f\u65e5\u306b\u3088\u3063\u3066\u5909\u308f\u308a\u307e\u3059\u3002\u3064\u307e\u308a\u3001\u30c7\u30fc\u30bf\u3054\u3068\u306b\u8a08\u7b97\u7bc4\u56f2\u304c\u5909\u308f\u308b\u3057\u3001\u5408\u8a08\u5024\u3092\u5165\u529b\u3059\u308b\u884c\u3082\u5909\u308f\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u672c\u90e8\u9577\u304b\u3089\u300c\u3069\u3046\u3059\u308c\u3070\u826f\u3044\u306e\uff1f\u300d\u3068\u3054\u76f8\u8ac7\u3092\u53d7\u3051\u305f\u3001\u3068\u4eee\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h2 id=\"i-1\"><span class=\"ez-toc-section\" id=\"%E7%89%B9%E5%AE%9A%E3%81%AE%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%81%AE%E8%A1%8C%E7%95%AA%E5%8F%B7%E3%82%92%E8%AA%BF%E3%81%B9%E3%81%A6%E3%80%81%E7%B8%A6%E6%96%B9%E5%90%91%E3%81%AE%E8%A8%88%E7%AE%97%E3%82%92%E3%81%99%E3%82%8B\"><\/span>\u7279\u5b9a\u306e\u30c6\u30ad\u30b9\u30c8\u306e\u884c\u756a\u53f7\u3092\u8abf\u3079\u3066\u3001\u7e26\u65b9\u5411\u306e\u8a08\u7b97\u3092\u3059\u308b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u3084\u308a\u65b9\u306f\u3044\u308d\u3044\u308d\u8003\u3048\u3089\u308c\u307e\u3059\u304c\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u300c\u5408\u8a08\u300d\u30c6\u30ad\u30b9\u30c8\u306e\u884c\u306e\u4f4d\u7f6e\u3092\u63a2\u3057\u3066\u5bfe\u5fdc\u3059\u308b\u30b3\u30fc\u30c9\u306e\u4f8b\u3092\u4e0b\u8a18\u306b\u63b2\u8f09\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vb decode:true\">Option Explicit\n\nSub Calc()\n\n'\u4f55\u884c\u76ee\u304b\u3089\u8a08\u7b97\u3059\u308b\u304b\nDim CalcStartRow As Integer: CalcStartRow = 3 '\u2605\n\n'\u4f55\u5217\u76ee\u304b\u3089\u8a08\u7b97\u3059\u308b\u304b\nDim CalcStartColName As String: CalcStartColName = \"B\" '\u2605\u540d\u524d\u3067\u6307\u5b9a\u3057\u305f\u307b\u3046\u304c\u5206\u304b\u308a\u3084\u3059\u3044\nDim CalcStartCol As Integer: CalcStartCol = Range(CalcStartColName &amp; \"1\").Column\n\n'\u4f55\u5217\u76ee\u307e\u3067\u8a08\u7b97\u3059\u308b\u304b\nDim CalcEndColName As String: CalcEndColName = \"G\" '\u2605\u540d\u524d\u3067\u6307\u5b9a\u3057\u305f\u307b\u3046\u304c\u5206\u304b\u308a\u3084\u3059\u3044\nDim CalcEndCol As Integer: CalcEndCol = Range(CalcEndColName &amp; \"1\").Column\n\n'\u300c\u5408\u8a08\u300d\u304c\u3042\u308b\u5217\nDim GokeiTextCol As Integer: GokeiTextCol = 1 '\u2605\n\n'\u300c\u5408\u8a08\u300d\u304c\u3042\u308b\u884c\uff08\u5909\u52d5\u3059\u308b\u306e\u3067\u691c\u7d22\u3057\u3066\u63a2\u3059\uff09\nDim GokeiTextRow As Integer: GokeiTextRow = 0\n\n'\u300c\u5408\u8a08\u300d\u304c\u4f55\u884c\u76ee\u306b\u3042\u308b\u304b\u306e\u691c\u7d22\u3092\u958b\u59cb\u3059\u308b\u884c\nDim GokeiSearchStartRow As Integer: GokeiSearchStartRow = 4 '\u2605\n\n'\u300c\u5408\u8a08\u300d\u304c\u4f55\u884c\u76ee\u306b\u3042\u308b\u304b\u306e\u691c\u7d22\u3092\u3042\u304d\u3089\u3081\u308b\u884c\nDim GokeiSearchEndRow As Integer: GokeiSearchEndRow = 100 '\u2605\n\n'\u5408\u8a08\u304c\u4f55\u884c\u76ee\u306b\u3042\u308b\u304b\u306e\u691c\u7d22\u3092\u5b9f\u884c\nDim CurRow As Integer\nFor CurRow = GokeiSearchStartRow To GokeiSearchEndRow\n    If Cells(CurRow, GokeiTextCol).Text = \"\u5408\u8a08\" Then\n        GokeiTextRow = CurRow '\u300c\u5408\u8a08\u300d\u304c\u898b\u3064\u304b\u3063\u305f\n        Exit For\n    End If\nNext\n\n'\u300c\u5408\u8a08\u300d\u304c\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f\u3089\u4e2d\u65ad\u3059\u308b\nIf GokeiTextRow &lt; GokeiSearchStartRow Then\n    Call MsgBox(\"\u300c\u5408\u8a08\u300d\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\", vbExclamation)\n    Exit Sub '\u7d42\u4e86\nEnd If\n\n'\u300c\u5408\u8a08\u300d\u306e\u884c\u306b\u8a08\u7b97\u5f0f\u3092\u8a2d\u5b9a\u3059\u308b\nDim CurCol As Integer\nFor CurCol = CalcStartCol To CalcEndCol '\u5217\u3054\u3068\u306b\u8a08\u7b97\u5f0f\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u304f\n    '\u305d\u306e\u5217\u306e\u8a08\u7b97\u3092\u958b\u59cb\u3059\u308b\u30bb\u30eb\n    Dim oCalcStartCell As Range: Set oCalcStartCell = Cells(CalcStartRow, CurCol)\n    '\u305d\u306e\u5217\u306e\u8a08\u7b97\u3092\u7d42\u4e86\u3059\u308b\u30bb\u30eb\n    Dim oCalcEndCell As Range: Set oCalcEndCell = Cells(GokeiTextRow - 1, CurCol)\n    '\u5408\u8a08\u3092\u6c42\u3081\u308b\u8a08\u7b97\u5f0f\u3092\u8a2d\u5b9a\n    Cells(GokeiTextRow, CurCol).Formula = \"=SUM(\" &amp; oCalcStartCell.AddressLocal &amp; \":\" &amp; oCalcEndCell.AddressLocal &amp; \")\"\nNext\n\nCall MsgBox(\"\u7d42\u4e86\u3057\u307e\u3057\u305f\u3002\", vbInformation)\n\nEnd Sub<\/pre>\n<p>&nbsp;<\/p>\n<p>\u3054\u81ea\u5206\u306e\u74b0\u5883\uff08\u30c7\u30fc\u30bf\u306e\u72b6\u614b\uff09\u306b\u5408\u308f\u305b\u3066\u8a2d\u5b9a\u3092\u5909\u3048\u308b\u3068\u3053\u308d\u306b\u2605\u3092\u5165\u308c\u3066\u304a\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u4e0b\u8a18\u306e\u3088\u3046\u306b\u3001\u5408\u8a08\u5024\u304c\u66f8\u304d\u8fbc\u307e\u308c\u307e\u3059\u3002\u3053\u308c\u3067\u3001\u30c7\u30fc\u30bf\u306b\u3088\u3063\u3066\u5ba2\u306e\u6570\uff08\u884c\u6570\uff09\u304c\u5909\u308f\u3063\u3066\u3082\u3001\u540c\u3058 VBA \u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u5bfe\u5fdc\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181004_6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4793 bigshadow\" src=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181004_6.png\" alt=\"\" width=\"537\" height=\"242\" srcset=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181004_6.png 537w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181004_6-300x135.png 300w\" sizes=\"auto, (max-width: 537px) 100vw, 537px\"><\/a><\/p>\n<p>\u30b7\u30fc\u30c8\u4e0a\u306e\u300c\u5408\u8a08\u300d\u306e\u30c6\u30ad\u30b9\u30c8\u4f4d\u7f6e\u3092\u6c42\u3081\u308b\u306b\u306f\u3001\u4ed6\u306b\u306f Find \u3092\u4f7f\u3046\u624b\u3082\u3042\u308a\u307e\u3059\u3057\u3001<br \/>\n\u307e\u305f\u306f\u300c\u5408\u8a08\u300d\u3092\u63a2\u3055\u306a\u304f\u3066\u3082\u3001\u30c7\u30fc\u30bf\u306e\u7d42\u4e86\u884c\u307e\u3067\uff08\u305d\u3057\u3066\u7d42\u4e86\u5217\u307e\u3067\uff09\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u5224\u5b9a\u3057\u3066\u8a08\u7b97\u3059\u308b\u65b9\u6cd5\u3082\u8003\u3048\u3089\u308c\u307e\u3059\u306d\u3002<\/p>\n<p>\u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u30c6\u30ad\u30b9\u30c8\u4f4d\u7f6e\u306e\u691c\u7d22\u65b9\u6cd5\u3060\u3051\u3067\u306a\u304f\u3001\u4ed6\u306b\u3082\u3044\u304f\u3064\u304b\u4f7f\u3048\u308b\u30c6\u30af\u30cb\u30c3\u30af\u304c\u5165\u3063\u3066\u308b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u3058\u3063\u304f\u308a\uff08\u306e\u3093\u3073\u308a\uff09\u773a\u3081\u3066\u3054\u53c2\u8003\u306b\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u4e0d\u660e\u70b9\u304c\u3042\u308c\u3070\u9060\u616e\u306a\u304f\u805e\u3044\u3066\u304f\u3060\u3055\u3044\u3002\u307e\u305f\u306e\u3054\u76f8\u8ac7\u3001\u304a\u5f85\u3061\u3057\u3066\u3044\u307e\u3059\uff01(^^)\/<\/p>\n<h2 id=\"i-2\"><span class=\"ez-toc-section\" id=\"%E7%89%B9%E5%AE%9A%E3%81%AE%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%81%AE%E8%A1%8C%E7%95%AA%E5%8F%B7%E3%82%92%E8%AA%BF%E3%81%B9%E3%81%A6%E3%80%81%E6%A8%AA%E6%96%B9%E5%90%91%E3%81%AE%E8%A8%88%E7%AE%97%E3%82%92%E3%81%99%E3%82%8B\"><\/span>\u7279\u5b9a\u306e\u30c6\u30ad\u30b9\u30c8\u306e\u884c\u756a\u53f7\u3092\u8abf\u3079\u3066\u3001\u6a2a\u65b9\u5411\u306e\u8a08\u7b97\u3092\u3059\u308b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\uff082010\u5e7410\u670817\u65e5\u8ffd\u8a18\u3002\u9234\u6728\u69d8\u3001\u30b3\u30e1\u30f3\u30c8\u6b04\u304b\u3089\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff01^^\uff09<\/p>\n<p>\u672c\u90e8\u9577\u304b\u3089\u8ffd\u52a0\u306e\u8cea\u554f\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<div class=\"sng-box box15\">\n<p>\u300c\u304a\u5ba2\u69d8\u305d\u308c\u305e\u308c\u306e\u5408\u8a08\u8cfc\u5165\u5546\u54c1\u6570\u300d\u3082\u51fa\u3057\u305f\u3044\u306e\u3060\u304c\uff1f<\/p>\n<\/div>\n<p>\u3068\u306e\u3053\u3068\u3067\u3059\u3002\u3064\u307e\u308a\u3001\u4eca\u5ea6\u306f\u8868\u306e\u6a2a\u65b9\u5411\u306e\u8a08\u7b97\u3092\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u524d\u8ff0\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u30b3\u30fc\u30c9\u3067\u5fc5\u8981\u306a\u884c\u756a\u53f7\u3084\u5217\u756a\u53f7\u306e\u591a\u304f\u304c\u3059\u3067\u306b\u53d6\u5f97\u3067\u304d\u3066\u3044\u308b\u306e\u3067\u3001\u305d\u308c\u3092\u5229\u7528\u3059\u308c\u3070\u697d\u3067\u3059\u306d\u3002\u300c\u5408\u8a08\u300d\u306e\u30c6\u30ad\u30b9\u30c8\u306e\u884c\u756a\u53f7\u3092\u8abf\u3079\u308b\u30b3\u30fc\u30c9\u3082\u65e2\u306b\u3067\u304d\u3066\u3044\u308b\u306e\u3067\u3001\u305d\u306e\u884c\u306e\u76f4\u524d\u306e\u884c\u307e\u3067\u8a08\u7b97\u5f0f\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\uff15\uff14\u884c\u76ee\u304b\u3089\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u305f\u306e\u3067\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"lang:vb mark:54-67 decode:true\">Option Explicit\n\nSub Calc()\n\n'\u4f55\u884c\u76ee\u304b\u3089\u8a08\u7b97\u3059\u308b\u304b\nDim CalcStartRow As Integer: CalcStartRow = 3 '\u2605\n\n'\u4f55\u5217\u76ee\u304b\u3089\u8a08\u7b97\u3059\u308b\u304b\nDim CalcStartColName As String: CalcStartColName = \"B\" '\u2605\u540d\u524d\u3067\u6307\u5b9a\u3057\u305f\u307b\u3046\u304c\u5206\u304b\u308a\u3084\u3059\u3044\nDim CalcStartCol As Integer: CalcStartCol = Range(CalcStartColName &amp; \"1\").Column\n\n'\u4f55\u5217\u76ee\u307e\u3067\u8a08\u7b97\u3059\u308b\u304b\nDim CalcEndColName As String: CalcEndColName = \"G\" '\u2605\u540d\u524d\u3067\u6307\u5b9a\u3057\u305f\u307b\u3046\u304c\u5206\u304b\u308a\u3084\u3059\u3044\nDim CalcEndCol As Integer: CalcEndCol = Range(CalcEndColName &amp; \"1\").Column\n\n'\u300c\u5408\u8a08\u300d\u304c\u3042\u308b\u5217\nDim GokeiTextCol As Integer: GokeiTextCol = 1 '\u2605\n\n'\u300c\u5408\u8a08\u300d\u304c\u3042\u308b\u884c\uff08\u5909\u52d5\u3059\u308b\u306e\u3067\u691c\u7d22\u3057\u3066\u63a2\u3059\uff09\nDim GokeiTextRow As Integer: GokeiTextRow = 0\n\n'\u300c\u5408\u8a08\u300d\u304c\u4f55\u884c\u76ee\u306b\u3042\u308b\u304b\u306e\u691c\u7d22\u3092\u958b\u59cb\u3059\u308b\u884c\nDim GokeiSearchStartRow As Integer: GokeiSearchStartRow = 4 '\u2605\n\n'\u300c\u5408\u8a08\u300d\u304c\u4f55\u884c\u76ee\u306b\u3042\u308b\u304b\u306e\u691c\u7d22\u3092\u3042\u304d\u3089\u3081\u308b\u884c\nDim GokeiSearchEndRow As Integer: GokeiSearchEndRow = 100 '\u2605\n\n'\u5408\u8a08\u304c\u4f55\u884c\u76ee\u306b\u3042\u308b\u304b\u306e\u691c\u7d22\u3092\u5b9f\u884c\nDim CurRow As Integer\nFor CurRow = GokeiSearchStartRow To GokeiSearchEndRow\n    If Cells(CurRow, GokeiTextCol).Text = \"\u5408\u8a08\" Then\n        GokeiTextRow = CurRow '\u300c\u5408\u8a08\u300d\u304c\u898b\u3064\u304b\u3063\u305f\n        Exit For\n    End If\nNext\n\n'\u300c\u5408\u8a08\u300d\u304c\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f\u3089\u4e2d\u65ad\u3059\u308b\nIf GokeiTextRow &lt; GokeiSearchStartRow Then\n    Call MsgBox(\"\u300c\u5408\u8a08\u300d\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\", vbExclamation)\n    Exit Sub '\u7d42\u4e86\nEnd If\n\n'\u300c\u5408\u8a08\u300d\u306e\u884c\u306b\u8a08\u7b97\u5f0f\u3092\u8a2d\u5b9a\u3059\u308b\nDim CurCol As Integer\nFor CurCol = CalcStartCol To CalcEndCol '\u5217\u3054\u3068\u306b\u8a08\u7b97\u5f0f\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u304f\n    '\u305d\u306e\u5217\u306e\u8a08\u7b97\u3092\u958b\u59cb\u3059\u308b\u30bb\u30eb\n    Dim oCalcStartCell As Range: Set oCalcStartCell = Cells(CalcStartRow, CurCol)\n    '\u305d\u306e\u5217\u306e\u8a08\u7b97\u3092\u7d42\u4e86\u3059\u308b\u30bb\u30eb\n    Dim oCalcEndCell As Range: Set oCalcEndCell = Cells(GokeiTextRow - 1, CurCol)\n    '\u5408\u8a08\u3092\u6c42\u3081\u308b\u8a08\u7b97\u5f0f\u3092\u8a2d\u5b9a\n    Cells(GokeiTextRow, CurCol).Formula = \"=SUM(\" &amp; oCalcStartCell.AddressLocal &amp; \":\" &amp; oCalcEndCell.AddressLocal &amp; \")\"\nNext\n\n'------ \u304a\u5ba2\u69d8\u305d\u308c\u305e\u308c\u306e\u5408\u8a08\u8cfc\u5165\u5546\u54c1\u6570 -----\n\n'\u304a\u5ba2\u69d8\u305d\u308c\u305e\u308c\u306e\u5408\u8a08\u8cfc\u5165\u5546\u54c1\u6570\u306e\u5f0f\u3092\u5165\u308c\u308b\u5217\nDim ShohinsuGokeiColName As String: ShohinsuGokeiColName = \"H\" '\u2605\u540d\u524d\u3067\u6307\u5b9a\u3057\u305f\u307b\u3046\u304c\u5206\u304b\u308a\u3084\u3059\u3044\nDim ShohinsuGokeiCol As Integer: ShohinsuGokeiCol = Range(ShohinsuGokeiColName &amp; \"1\").Column\n\nFor CurRow = CalcStartRow To GokeiTextRow - 1\n    '\u305d\u306e\u884c\u306e\u8a08\u7b97\u3092\u958b\u59cb\u3059\u308b\u30bb\u30eb\n    Set oCalcStartCell = Cells(CurRow, CalcStartCol)\n    '\u305d\u306e\u884c\u306e\u8a08\u7b97\u3092\u7d42\u4e86\u3059\u308b\u30bb\u30eb\n    Set oCalcEndCell = Cells(CurRow, CalcEndCol)\n    '\u5408\u8a08\u3092\u6c42\u3081\u308b\u8a08\u7b97\u5f0f\u3092\u8a2d\u5b9a\n    Cells(CurRow, ShohinsuGokeiCol).Formula = \"=SUM(\" &amp; oCalcStartCell.AddressLocal &amp; \":\" &amp; oCalcEndCell.AddressLocal &amp; \")\"\nNext\n\nCall MsgBox(\"\u7d42\u4e86\u3057\u307e\u3057\u305f\u3002\", vbInformation)\n\nEnd Sub<\/pre>\n<p>&nbsp;<\/p>\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u4e0b\u8a18\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181017.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5255 bigshadow\" src=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181017.png\" alt=\"\" width=\"612\" height=\"255\" srcset=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181017.png 612w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181017-300x125.png 300w\" sizes=\"auto, (max-width: 612px) 100vw, 612px\"><\/a><\/p>\n<h2 id=\"i-3\"><span class=\"ez-toc-section\" id=\"%E6%A9%9F%E8%83%BD%E3%82%92%E3%82%B5%E3%83%96%E3%83%AB%E3%83%BC%E3%83%81%E3%83%B3%E3%81%AB%E5%88%86%E3%81%91%E3%82%8B\"><\/span>\u6a5f\u80fd\u3092\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u306b\u5206\u3051\u308b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u672c\u90e8\u9577\u304b\u3089\u307e\u305f\u3054\u9023\u7d61\u3092\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002\uff082010\u5e7410\u670817\u65e5\u8ffd\u8a18\uff09<\/p>\n<div class=\"sng-box box15\">\n<p>\u304a\u5f01\u5f53\u304b\u3089\u304a\u83d3\u5b50\u307e\u3067\u306e\u5408\u8a08\u3092\u300c\u98df\u54c1\u5408\u8a08\u300d\u3068\u3057\u3066 I \u5217\u3001\u304a\u9152\u304b\u3089\u96d1\u8a8c\u307e\u3067\u306e\u5408\u8a08\u3092\u300c\u305d\u306e\u4ed6\u300d\u3068\u3057\u3066 J \u5217\u306b\u5165\u308c\u308b\u306b\u306f\u3069\u3046\u3057\u305f\u3089\u826f\u3044\u304b\uff1f<\/p>\n<\/div>\n<p>\u3068\u3044\u3046\u3054\u8cea\u554f\u3067\u3059\u3002<\/p>\n<p>\u57fa\u672c\u7684\u306b\u306f\u524d\u8ff0\u306e\u30b3\u30fc\u30c9\u306e\u300c\u304a\u5ba2\u69d8\u305d\u308c\u305e\u308c\u306e\u5408\u8a08\u8cfc\u5165\u5546\u54c1\u6570\u300d\u306e\u90e8\u5206\uff08\uff15\uff14\u884c\u76ee\uff5e\uff16\uff17\u884c\u76ee\uff09\u3068\u540c\u3058\u3053\u3068\u3092\u3042\u3068\uff12\u56de\u3084\u308c\u3070\u826f\u3044\u308f\u3051\u3067\u3059\u304c\u3001\u4f3c\u305f\u3088\u3046\u306a\u51e6\u7406\u306e\u30b3\u30fc\u30c9\u3092\uff13\u56de\u3082\u540c\u3058\u95a2\u6570\u5185\u306b\u66f8\u304f\u306e\u306f\u3042\u307e\u308a\u30b9\u30de\u30fc\u30c8\u306a\u3084\u308a\u65b9\u3067\u306f\u306a\u3044\u3067\u3059\u306d\u3002\u305d\u3046\u3044\u3046\u66f8\u304d\u65b9\u3092\u3057\u7d9a\u3051\u308b\u3068\u30b3\u30fc\u30c9\u5168\u4f53\u304c\u898b\u8f9b\u304f\u306a\u308a\u3001\u3042\u3068\u3042\u3068\u30e1\u30f3\u30c6\u3082\u3084\u308a\u306b\u304f\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\u3001\u305d\u308d\u305d\u308d\u524d\u8ff0\u306e\u30b3\u30fc\u30c9\u3092\u3044\u304f\u3064\u304b\u306e\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u306b\u5206\u3051\u3064\u3064\u3001\u4eca\u56de\u306e\u672c\u90e8\u9577\u306e\u3054\u5e0c\u671b\u306b\u6cbf\u3046\u3088\u3046\u5bfe\u5fdc\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u30b3\u30fc\u30c9\u3092\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u306b\u5206\u3051\u308b\u3068\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u30b3\u30fc\u30c9\u5168\u4f53\u304c\u6574\u7406\u3055\u308c\u3066\u898b\u3084\u3059\u304f\u306a\u308b<\/li>\n<li>\uff11\u3064\u306e\u95a2\u6570\u306e\u884c\u6570\u304c\u77ed\u304f\u306a\u308a\u3001\u51e6\u7406\u5185\u5bb9\u3092\u628a\u63e1\u3057\u3084\u3059\u304f\u306a\u308b<\/li>\n<li>\u4f3c\u305f\u3088\u3046\u306a\u51e6\u7406\u3092\u4f55\u56de\u3082\u8a18\u8ff0\u305b\u305a\u306b\u6e08\u3080<\/li>\n<li>\u7279\u5b9a\u306e\u51e6\u7406\u3092\u884c\u3046\u95a2\u6570\u3092\u90e8\u54c1\u3068\u3057\u3066\u518d\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\uff08\u5225\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308b\u3068\u304d\u306b\u3082\u5229\u7528\u3067\u304d\u308b\uff09<\/li>\n<\/ul>\n<p>\u3060\u3044\u305f\u3044\u3053\u3093\u306a\u3068\u3053\u308d\u304b\u306a\uff1f \u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u306b\u5206\u5272\u3059\u308b\u969b\u306e\u6ce8\u610f\u70b9\u3068\u3057\u3066\u3001\u30e1\u30a4\u30f3\u3068\u306a\u308b\u30eb\u30fc\u30c1\u30f3\u3092\u898b\u308b\u3060\u3051\u3067\u5168\u4f53\u306e\u51e6\u7406\u306e\u6d41\u308c\u3092\u628a\u63e1\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u304c\u5927\u5207\u3067\u3059\u3002<\/p>\n<p>\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\u306b\u5206\u5272\u3057\u3066\u3001\u672c\u90e8\u9577\u306e\u3054\u610f\u5411\u3092\u53cd\u6620\u3057\u305f\u30b3\u30fc\u30c9\u3092\u4e0b\u8a18\u306b\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:vb decode:true  \">Option Explicit\n\nSub Calc()\n\n'\u4f55\u884c\u76ee\u304b\u3089\u8a08\u7b97\u3059\u308b\u304b\nDim CalcStartRow As Integer: CalcStartRow = 3 '\u2605\n\n'\u300c\u5408\u8a08\u300d\u306e\u30c6\u30ad\u30b9\u30c8\u304c\u3042\u308b\u884c\u3092\u6c42\u3081\u308b\u3000\u2605\u300c\u5408\u8a08\u300d\u304c\u3042\u308b\u5217\u3001\u300c\u5408\u8a08\u300d\u306e\u691c\u7d22\u3092\u958b\u59cb\u3059\u308b\u884c\u3001\u300c\u5408\u8a08\u300d\u306e\u691c\u7d22\u3092\u3042\u304d\u3089\u3081\u308b\u884c\u3092\u6307\u5b9a\nDim GokeiTextRow As Integer: GokeiTextRow = GetGokeiTextRow(1, CalcStartRow + 1, 100)\n\n'\u300c\u5408\u8a08\u300d\u304c\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f\u3089\u4e2d\u65ad\u3059\u308b\nIf GokeiTextRow &lt;= CalcStartRow Then\n    Call MsgBox(\"\u300c\u5408\u8a08\u300d\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\", vbExclamation)\n    Exit Sub '\u7d42\u4e86\nEnd If\n\n'\u5546\u54c1\u3054\u3068\u306e\u5546\u54c1\u6570\u306e\u5408\u8a08\u3092\u6c42\u3081\u308b  \u2605\u8a08\u7b97\u958b\u59cb\u5217\u306e\u540d\u524d\u3001\u8a08\u7b97\u7d42\u4e86\u5217\u306e\u540d\u524d\u3092\u6307\u5b9a\nCall ShokuhinsuGokei_PerItem(CalcStartRow, GokeiTextRow, \"B\", \"G\")\n\n'\u5ba2\u3054\u3068\u306e\u5546\u54c1\u6570\uff08\u5168\u5546\u54c1\uff09\u306e\u5408\u8a08\u3092\u6c42\u3081\u308b \u2605\u8a08\u7b97\u958b\u59cb\u5217\u306e\u540d\u524d\u3001\u8a08\u7b97\u7d42\u4e86\u5217\u306e\u540d\u524d\u3001\u8a08\u7b97\u5f0f\u5165\u529b\u5217\u306e\u540d\u524d\u3092\u6307\u5b9a\nCall ShokuhinsuGokei_PerCustomer(CalcStartRow, GokeiTextRow - 1, \"B\", \"G\", \"H\")\n\n'\u5ba2\u3054\u3068\u306e\u5546\u54c1\u6570\uff08\u98df\u54c1\uff09\u306e\u5408\u8a08\u3092\u6c42\u3081\u308b \u2605\u8a08\u7b97\u958b\u59cb\u5217\u306e\u540d\u524d\u3001\u8a08\u7b97\u7d42\u4e86\u5217\u306e\u540d\u524d\u3001\u8a08\u7b97\u5f0f\u5165\u529b\u5217\u306e\u540d\u524d\u3092\u6307\u5b9a\nCall ShokuhinsuGokei_PerCustomer(CalcStartRow, GokeiTextRow - 1, \"B\", \"E\", \"I\")\n\n'\u5ba2\u3054\u3068\u306e\u5546\u54c1\u6570\uff08\u305d\u306e\u4ed6\uff09\u306e\u5408\u8a08\u3092\u6c42\u3081\u308b \u2605\u8a08\u7b97\u958b\u59cb\u5217\u306e\u540d\u524d\u3001\u8a08\u7b97\u7d42\u4e86\u5217\u306e\u540d\u524d\u3001\u8a08\u7b97\u5f0f\u5165\u529b\u5217\u306e\u540d\u524d\u3092\u6307\u5b9a\nCall ShokuhinsuGokei_PerCustomer(CalcStartRow, GokeiTextRow - 1, \"F\", \"G\", \"J\")\n\nCall MsgBox(\"\u7d42\u4e86\u3057\u307e\u3057\u305f\u3002\", vbInformation)\n\nEnd Sub\n\n'==========================================================================\n\n'\u300c\u5408\u8a08\u300d\u306e\u30c6\u30ad\u30b9\u30c8\u304c\u3042\u308b\u884c\u3092\u6c42\u3081\u308b\nFunction GetGokeiTextRow(GokeiTextCol As Integer, GokeiSearchStartRow As Integer, GokeiSearchEndRow As Integer) As Integer\n\nDim GokeiTextRow As Integer: GokeiTextRow = 0\n\n'\u5408\u8a08\u304c\u4f55\u884c\u76ee\u306b\u3042\u308b\u304b\u306e\u691c\u7d22\u3092\u5b9f\u884c\nDim CurRow As Integer\nFor CurRow = GokeiSearchStartRow To GokeiSearchEndRow\n    If Cells(CurRow, GokeiTextCol).Text = \"\u5408\u8a08\" Then\n        GokeiTextRow = CurRow '\u300c\u5408\u8a08\u300d\u304c\u898b\u3064\u304b\u3063\u305f\n        Exit For\n    End If\nNext\n\nGetGokeiTextRow = GokeiTextRow\n\nEnd Function\n\n'==========================================================================\n\n'\u5546\u54c1\u3054\u3068\u306e\u5546\u54c1\u6570\u306e\u5408\u8a08\u3092\u6c42\u3081\u308b\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\n\nSub ShokuhinsuGokei_PerItem(CalcStartRow As Integer, GokeiTextRow As Integer, CalcStartColName As String, CalcEndColName As String)\n\n'\u4f55\u5217\u76ee\u304b\u3089\u8a08\u7b97\u3059\u308b\u304b\nDim CalcStartCol As Integer: CalcStartCol = ColName2ColNumber(CalcStartColName)\n\n'\u4f55\u5217\u76ee\u307e\u3067\u8a08\u7b97\u3059\u308b\u304b\nDim CalcEndCol As Integer: CalcEndCol = ColName2ColNumber(CalcEndColName)\n\n'\u300c\u5408\u8a08\u300d\u306e\u884c\u306b\u8a08\u7b97\u5f0f\u3092\u8a2d\u5b9a\u3059\u308b\nDim CurCol As Integer\nFor CurCol = CalcStartCol To CalcEndCol '\u5217\u3054\u3068\u306b\u8a08\u7b97\u5f0f\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u304f\n    '\u305d\u306e\u5217\u306e\u8a08\u7b97\u3092\u958b\u59cb\u3059\u308b\u30bb\u30eb\n    Dim oCalcStartCell As Range: Set oCalcStartCell = Cells(CalcStartRow, CurCol)\n    '\u305d\u306e\u5217\u306e\u8a08\u7b97\u3092\u7d42\u4e86\u3059\u308b\u30bb\u30eb\n    Dim oCalcEndCell As Range: Set oCalcEndCell = Cells(GokeiTextRow - 1, CurCol)\n    '\u5408\u8a08\u3092\u6c42\u3081\u308b\u8a08\u7b97\u5f0f\u3092\u8a2d\u5b9a\n    Cells(GokeiTextRow, CurCol).Formula = \"=SUM(\" &amp; oCalcStartCell.AddressLocal &amp; \":\" &amp; oCalcEndCell.AddressLocal &amp; \")\"\nNext\n\nEnd Sub\n\n'==========================================================================\n\n'\u5ba2\u3054\u3068\u306e\u5546\u54c1\u6570\u306e\u5408\u8a08\u3092\u6c42\u3081\u308b\u30b5\u30d6\u30eb\u30fc\u30c1\u30f3\n\nSub ShokuhinsuGokei_PerCustomer(CalcStartRow As Integer, CalcEndRow As Integer, CalcStartColName As String, CalcEndColName As String, ShohinsuGokeiColName As String)\n\n'\u4f55\u5217\u76ee\u304b\u3089\u8a08\u7b97\u3059\u308b\u304b\nDim CalcStartCol As Integer: CalcStartCol = ColName2ColNumber(CalcStartColName)\n\n'\u4f55\u5217\u76ee\u307e\u3067\u8a08\u7b97\u3059\u308b\u304b\nDim CalcEndCol As Integer: CalcEndCol = ColName2ColNumber(CalcEndColName)\n\n'\u5546\u54c1\u306e\u5408\u8a08\u3092\u6c42\u3081\u308b\u5f0f\u3092\u5165\u529b\u3059\u308b\u5217\nDim ShohinsuGokeiCol As Integer: ShohinsuGokeiCol = ColName2ColNumber(ShohinsuGokeiColName)\n\nDim CurRow As Integer\nDim oCalcStartCell As Range\nDim oCalcEndCell As Range\n\nFor CurRow = CalcStartRow To CalcEndRow\n    '\u305d\u306e\u884c\u306e\u8a08\u7b97\u3092\u958b\u59cb\u3059\u308b\u30bb\u30eb\n    Set oCalcStartCell = Cells(CurRow, CalcStartCol)\n    '\u305d\u306e\u884c\u306e\u8a08\u7b97\u3092\u7d42\u4e86\u3059\u308b\u30bb\u30eb\n    Set oCalcEndCell = Cells(CurRow, CalcEndCol)\n    '\u5408\u8a08\u3092\u6c42\u3081\u308b\u8a08\u7b97\u5f0f\u3092\u8a2d\u5b9a\n    Cells(CurRow, ShohinsuGokeiCol).Formula = \"=SUM(\" &amp; oCalcStartCell.AddressLocal &amp; \":\" &amp; oCalcEndCell.AddressLocal &amp; \")\"\nNext\n\nEnd Sub\n\n'==========================================================================\n\n'\u5217\u540d\u3092\u5217\u756a\u53f7\u306b\u5909\u63db\u3059\u308b\nFunction ColName2ColNumber(ColName As String) As Integer\n\nDim ColNumber As Integer: ColNumber = Range(ColName &amp; \"1\").Column\n\nColName2ColNumber = ColNumber\n\nEnd Function\n\n\n\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u4e0b\u56f3\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181017b.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5263\" src=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181017b.png\" alt=\"\" width=\"839\" height=\"563\" srcset=\"https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181017b.png 839w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181017b-300x201.png 300w, https:\/\/elleneast.com\/wp\/wp-content\/uploads\/programming_topics\/VBA\/20181017b-768x515.png 768w\" sizes=\"auto, (max-width: 839px) 100vw, 839px\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u5206\u304b\u3089\u306a\u3044\u3068\u3053\u308d\u304c\u3042\u308c\u3070\u805e\u3044\u3066\u304f\u3060\u3055\u3044\u3002\u307e\u305f\u4f55\u304b\u3042\u308a\u307e\u3057\u305f\u3089\u9060\u616e\u306a\u304f\u3069\u3046\u305e\uff01(*^-^*)<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u77e5\u308a\u5408\u3044\u306e\u65b9\u304b\u3089 Excel VBA \u306b\u3064\u3044\u3066\u8cea\u554f\u3092\u3044\u305f\u3060\u3044\u305f\u306e\u3067\u3001\u30d6\u30ed\u30b0\u30cd\u30bf\u306b\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002 \u8cea\u554f\u5185\u5bb9 \u8cea\u554f\u5185\u5bb9\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002 A \u5217\u306b\u300c\u5408\u8a08\u300d\u3068\u51fa\u3066\u304d\u305f\u3089\u3001\u305d\u306e\u884c\u3068\u540c\u3058 B \u5217\u306e\u30bb\u30eb\u306b B \u5217\u306e\u5408\u8a08\u5024\u3092\u5165\u308c\u305f &#8230; <\/p>\n","protected":false},"author":1,"featured_media":2420,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[57],"tags":[74,46],"class_list":{"0":"post-4764","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-57","8":"tag-excel-vba","9":"tag-vba"},"_links":{"self":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/4764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4764"}],"version-history":[{"count":3,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/4764\/revisions"}],"predecessor-version":[{"id":5269,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/posts\/4764\/revisions\/5269"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=\/wp\/v2\/media\/2420"}],"wp:attachment":[{"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elleneast.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}