{"id":3092,"date":"2020-01-26T00:44:55","date_gmt":"2020-01-25T15:44:55","guid":{"rendered":"https:\/\/okamurax.com\/?p=3092"},"modified":"2020-01-27T21:03:45","modified_gmt":"2020-01-27T12:03:45","slug":"vba-%e6%89%8b%e4%bd%9c%e3%82%8a%e3%82%ab%e3%83%ac%e3%83%b3%e3%83%80%e3%83%bc","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=3092","title":{"rendered":"VBA \u8868\u304b\u3089\u30ab\u30ec\u30f3\u30c0\u30fc\u5f62\u5f0f\u306b\u5909\u63db"},"content":{"rendered":"<p>\u524d\u56de\u306fJavascript\/C#\u7248\u3067\u4eca\u56de\u306fVBA\u7248<\/p>\n<p>\u25cb\u25cb\u8868\u3068\u3044\u3046\u611f\u3058\u306e\u5e33\u7968\u3092\u4f5c\u308b\u5834\u5408\u3001\u884c\u304c\u5358\u4f4d\u3067\u5217\u304c\u660e\u7d30\u3068\u3044\u3046\u306e\u304c\u4e00\u822c\u7684\u3002<\/p>\n<p>\u660e\u7d30\u306e\u4e2d\u306b\u7d0d\u671f\u3084\u51fa\u8377\u65e5\u306a\u3069\u65e5\u4ed8\u306b\u95a2\u308f\u308b\u60c5\u5831\u304c\u5165\u3063\u3066\u3044\u308b\u3053\u3068\u3082\u591a\u304f\u3001\u305d\u3053\u3067\u554f\u984c\u306b\u306a\u308b\u306e\u304c\u3001\u3053\u306e\u65e5\u4ed8\u60c5\u5831\u540c\u58eb\u306e\u95a2\u4fc2\u6027\u304c\u30d1\u30c3\u3068\u628a\u63e1\u3067\u304d\u306a\u3044\u3053\u3068\u3002<\/p>\n<p>\u65e5\u4ed8\u60c5\u5831\u304c\u304a\u307e\u3051\u306e\u5834\u5408\u306f\u3044\u3044\u3051\u3069\u3001\u65e5\u4ed8\u60c5\u5831\u304c\u91cd\u8981\u306a\u5834\u5408\u306f\u628a\u63e1\u3057\u3084\u3059\u3044\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306b\u5909\u63db\u3057\u3066\u307f\u3088\u3046\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u8868\u304b\u3089\u30ab\u30ec\u30f3\u30c0\u30fc\u306b\u5909\u63db\u3059\u308b\u6a5f\u80fd\u3092\u4f5c\u6210\u3057\u3066\u307f\u305f\u3002<\/p>\n<p>\u30eb\u30fc\u30d7\u304c\uff12\u91cd\u306b\u306a\u308b\u306e\u3067\u3001\u884c\u6570\u304c\u591a\u3044\u5834\u5408\u306f\u5de5\u592b\u3057\u305f\u307b\u3046\u304c\u3044\u3044\u304b\u3082\u3057\u308c\u306a\u3044\u3002\u884c\u6570\u304c\u5c11\u306a\u3051\u308c\u3070\u554f\u984c\u306a\u3044\u3068\u601d\u3046\u3002<\/p>\n<pre class=\"lang:vb decode:true \">Sub CreateCalendar()\r\n\r\ny = 2020\r\nm = 1\r\n\r\nFor Each w In Sheets\r\n  If w.Name = \"\u30ab\u30ec\u30f3\u30c0\" Then\r\n    w.Delete\r\n    Exit For\r\n  End If\r\nNext\r\n\r\nSet w = Sheets.Add\r\nw.Name = \"\u30ab\u30ec\u30f3\u30c0\"\r\n\r\n' value\r\n\r\nw.Cells(1, 1).Value = y &amp; \"\u5e74\" &amp; m &amp; \"\u6708\"\r\n\r\nw.Cells(2, 1).Value = \"\u65e5\"\r\nw.Cells(2, 2).Value = \"\u6708\"\r\nw.Cells(2, 3).Value = \"\u706b\"\r\nw.Cells(2, 4).Value = \"\u6c34\"\r\nw.Cells(2, 5).Value = \"\u6728\"\r\nw.Cells(2, 6).Value = \"\u91d1\"\r\nw.Cells(2, 7).Value = \"\u571f\"\r\n\r\nstartWeekDay = Weekday(DateSerial(y, m, 1)) ' \u65e51, \u67082, \u706b3, \u6c344, \u67285, \u91d16, \u571f7\r\n\r\ntmp = DateAdd(\"m\", 1, DateSerial(y, m, 1))\r\nendDay = Day(DateAdd(\"d\", -1, tmp))\r\n\r\ncounter = 1\r\n\r\nFor r = 3 To 13 Step 2\r\n\r\n  For c = 1 To 7\r\n  \r\n    If (r = 3 And c &lt; startWeekDay) Or (counter &gt; endDay) Then\r\n    \r\n    Else\r\n    \r\n      w.Cells(r, c).Value = counter\r\n      w.Cells(r + 1, c).Value = GetValue(y, m, counter)\r\n      \r\n      counter = counter + 1\r\n    \r\n    End If\r\n    \r\n  Next\r\n\r\nNext\r\n\r\n' size\r\n\r\nw.Columns(\"A:G\").ColumnWidth = 17\r\n\r\nw.Rows(1).RowHeight = 24\r\n\r\nFor Each r In Split(\"2,3,5,7,9,11,13\", \",\")\r\n  w.Rows(r).RowHeight = 17\r\nNext\r\n\r\nFor Each r In Split(\"4,6,8,10,12,14\", \",\")\r\n  w.Rows(r).RowHeight = 69\r\nNext\r\n\r\n' position\r\n\r\nw.Range(\"A2:G2\").HorizontalAlignment = xlCenter\r\n\r\nFor Each r In Split(\"3,5,7,9,11,13\", \",\")\r\n  w.Rows(r).HorizontalAlignment = xlLeft\r\nNext\r\n\r\n' border\r\n\r\nFor Each r In Split(\"2,3,5,7,9,11,13,15\", \",\")\r\n  w.Range(w.Cells(CInt(r), 1), w.Cells(CInt(r), 7)).Borders(xlEdgeTop).LineStyle = xlContinuous\r\nNext\r\n\r\nFor Each c In Split(\"1,2,3,4,5,6,7,8\", \",\")\r\n  w.Range(w.Cells(2, CInt(c)), w.Cells(14, CInt(c))).Borders(xlEdgeLeft).LineStyle = xlContinuous\r\nNext\r\n\r\nEnd Sub\r\n\r\nFunction GetValue(y, m, d)\r\n\r\nsheetName = \"Sheet1\"\r\nmatchColumn = 3\r\nvalueColumn = 2\r\nstartRow = 2\r\nendRow = 11\r\n\r\nFor r = startRow To endRow\r\n\r\n  If DateSerial(y, m, d) = Sheets(sheetName).Cells(r, matchColumn).Value Then\r\n    GetValue = Sheets(sheetName).Cells(r, valueColumn).Value\r\n    Exit Function\r\n  End If\r\n\r\nNext\r\n\r\nEnd Function\r\n\r\n<\/pre>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/C1l38nUFUTw\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306fJavascript\/C#\u7248\u3067\u4eca\u56de\u306fVBA\u7248 \u25cb\u25cb\u8868\u3068\u3044\u3046\u611f\u3058\u306e\u5e33\u7968\u3092\u4f5c\u308b\u5834\u5408\u3001\u884c\u304c\u5358\u4f4d\u3067\u5217\u304c\u660e\u7d30\u3068\u3044\u3046\u306e\u304c\u4e00\u822c\u7684\u3002 \u660e\u7d30\u306e\u4e2d\u306b\u7d0d\u671f\u3084\u51fa\u8377\u65e5\u306a\u3069\u65e5\u4ed8\u306b\u95a2\u308f\u308b\u60c5\u5831\u304c\u5165\u3063\u3066\u3044\u308b\u3053\u3068\u3082\u591a\u304f\u3001\u305d\u3053\u3067\u554f\u984c\u306b\u306a\u308b\u306e\u304c\u3001\u3053\u306e\u65e5\u4ed8 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=3092\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;VBA \u8868\u304b\u3089\u30ab\u30ec\u30f3\u30c0\u30fc\u5f62\u5f0f\u306b\u5909\u63db&#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-3092","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\/3092","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=3092"}],"version-history":[{"count":12,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/3092\/revisions"}],"predecessor-version":[{"id":3107,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/3092\/revisions\/3107"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}