{"id":2764,"date":"2019-08-16T12:04:17","date_gmt":"2019-08-16T03:04:17","guid":{"rendered":"http:\/\/okamurax.com\/?p=2764"},"modified":"2020-01-15T11:24:53","modified_gmt":"2020-01-15T02:24:53","slug":"vba-%e8%a1%a8%e3%81%8b%e3%82%89%e8%a1%8c","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=2764","title":{"rendered":"VBA \u8868\u304b\u3089\u884c"},"content":{"rendered":"<p>\u7279\u5b9a\u306e\u7bc4\u56f2\u306e\u30c7\u30fc\u30bf\u3092\u30ea\u30b9\u30c8\u5316\u3059\u308b\u5834\u5408\u3001\u5b9a\u756a\u306a\u306e\u306f\u884c\u3068\u5217\u306e\u30eb\u30fc\u30d7\u3092\u30cd\u30b9\u30c8\u3055\u305b\u308b\u65b9\u6cd5\u3002<\/p>\n<p>\u884c\u306e\u5909\u6570(r)\u3068\u5217(c)\u306e\u5909\u6570\u3092Cells\u3067\u5229\u7528\u3059\u308c\u3070OK\u3002\u898b\u51fa\u3057\u7b49\u306f\u884c\u3084\u5217\u306e\u6570\u5024\u3092\u56fa\u5b9a\u306b\u3059\u308b\u3002<\/p>\n<pre class=\"lang:vb decode:true \">Sub test()\r\n\r\nSet fw = Sheets(\"f\")\r\nSet tw = Sheets(\"t\")\r\n\r\ntw.Cells.Delete\r\ntargetRow = 1\r\n \r\nFor c = 3 To 16\r\n  For r = 3 To 258 Step 5\r\n \r\n    staff = fw.Cells(r, 1).Value '\u5217\u304c\u56fa\u5b9a\u306e\u5834\u5408\r\n    ym = fw.Cells(2, c).Value ' \u884c\u304c\u56fa\u5b9a\u306e\u5834\u5408\r\n    \r\n    price1 = fw.Cells(r, c).Value\r\n    price2 = fw.Cells(r + 1, c).Value\r\n    note1 = fw.Cells(r + 2, c).Value\r\n    note2 = fw.Cells(r + 3, c).Value\r\n    note3 = fw.Cells(r + 4, c).Value\r\n    \r\n    tw.Cells(targetRow, 1).Value = staff\r\n    tw.Cells(targetRow, 2).Value = ym\r\n    tw.Cells(targetRow, 3).Value = price1\r\n    tw.Cells(targetRow, 4).Value = price2\r\n    tw.Cells(targetRow, 5).Value = note1\r\n    tw.Cells(targetRow, 6).Value = note2\r\n    tw.Cells(targetRow, 7).Value = note3\r\n    \r\n    targetRow = targetRow + 1\r\n \r\n  Next r\r\nNext c\r\n \r\nEnd Sub\r\n<\/pre>\n<pre class=\"lang:vb decode:true \">Sub test2()\r\n\r\nr_start = 2\r\nc_start = 3\r\n\r\nr_count = 4\r\nc_count = 5\r\n\r\nl_start = 3\r\n\r\nFor r = r_start To r_start + r_count - 1\r\n  For c = c_start To c_start + c_count - 1\r\n    ActiveSheet.Cells(r, c).Value = r &amp; \"\u884c\" &amp; \", \" &amp; c &amp; \"\u5217\"\r\n  Next\r\nNext\r\n\r\nFor r = r_start To r_start + r_count - 1\r\n  For c = c_start To c_start + c_count - 1\r\n    ActiveSheet.Cells(l_start, 1).Value = ActiveSheet.Cells(r, c).Value\r\n    l_start = l_start + 1\r\n  Next\r\nNext\r\n\r\nEnd Sub\r\n<\/pre>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/maF3gjFAKDw\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7279\u5b9a\u306e\u7bc4\u56f2\u306e\u30c7\u30fc\u30bf\u3092\u30ea\u30b9\u30c8\u5316\u3059\u308b\u5834\u5408\u3001\u5b9a\u756a\u306a\u306e\u306f\u884c\u3068\u5217\u306e\u30eb\u30fc\u30d7\u3092\u30cd\u30b9\u30c8\u3055\u305b\u308b\u65b9\u6cd5\u3002 \u884c\u306e\u5909\u6570(r)\u3068\u5217(c)\u306e\u5909\u6570\u3092Cells\u3067\u5229\u7528\u3059\u308c\u3070OK\u3002\u898b\u51fa\u3057\u7b49\u306f\u884c\u3084\u5217\u306e\u6570\u5024\u3092\u56fa\u5b9a\u306b\u3059\u308b\u3002 Sub test() Set fw = &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=2764\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;VBA \u8868\u304b\u3089\u884c&#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-2764","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\/2764","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=2764"}],"version-history":[{"count":5,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2764\/revisions"}],"predecessor-version":[{"id":2939,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/2764\/revisions\/2939"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}