{"id":1999,"date":"2017-11-01T11:51:10","date_gmt":"2017-11-01T02:51:10","guid":{"rendered":"http:\/\/okamurax.com\/?p=1999"},"modified":"2022-12-16T10:31:54","modified_gmt":"2022-12-16T01:31:54","slug":"vba-%e6%9d%a1%e4%bb%b6%e4%bb%98%e3%81%8d%e6%9b%b8%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=1999","title":{"rendered":"VBA \u6761\u4ef6\u4ed8\u304d\u66f8\u5f0f"},"content":{"rendered":"<pre class=\"lang:vb decode:true \">Sub CellsCondition()\r\n\r\n' \u6761\u4ef6\u4ed8\u66f8\u5f0f\u30af\u30ea\u30a2\r\n\r\nSet w = Sheets(\"11\u6708\")\r\n\r\n'w.Cells.FormatConditions.Delete\r\nw.Columns(\"J\").FormatConditions.Delete\r\n\r\n' \u6700\u7d42\u884c\u53d6\u5f97\r\n\r\n'b = w.UsedRange.Rows.Count\r\nb = 324\r\n\r\nFor r = 2 To b\r\n  For c = 10 To 10 ' J\u5217\u306e\u307f\r\n  \r\n    ' A\u5217\u306e\u5024(Weekday)\u304c1\u306a\u3089\u8d64\r\n    'Set f = w.Cells(r, c).FormatConditions.Add(xlExpression, xlEqual, \"=Weekday(A\" &amp; r &amp; \")=1\")\r\n    'f.Interior.Color = RGB(255, 200, 200)\r\n    'f.StopIfTrue = False\r\n\r\n    ' A\u5217\u306e\u5024(Weekday)\u304c7\u306a\u3089\u9752(\u8907\u6570\u6761\u4ef6)\r\n    'Set f = w.Cells(r, c).FormatConditions.Add(xlExpression, xlEqual, \"=AND(B\" &amp; r &amp; \"=0,Weekday(A\" &amp; r &amp; \")=7)\")\r\n    'f.Interior.Color = RGB(200, 200, 255)\r\n    'f.StopIfTrue = False\r\n\r\n    ' \u91cd\u8907\u30c1\u30a7\u30c3\u30af\uff0b\u7279\u5b9a\u306e\u5358\u8a9e\u3092\u9664\u5916\r\n    'Set f = w.Cells(r, c).FormatConditions.Add(xlExpression, xlEqual, \"=AND(COUNTIF(J2:J324,J\" &amp; r &amp; \")&gt;1,J\" &amp; r &amp; \"&lt;&gt;\"\"\uff7c\uff7a\uff90\"\")\")\r\n    'f.Interior.Color = RGB(255, 0, 0)\r\n    'f.StopIfTrue = False\r\n\r\n    ' A\u5217\u306e\u5024\u304c1\u306a\u3089\u66f8\u5f0f\u8a2d\u5b9a\r\n    'Set f = w.Cells(r, 1).FormatConditions.Add(xlExpression, xlEqual, \"=Day(A\" &amp; r &amp; \")=1\")\r\n    'f.NumberFormat = \"mm\/dd(aaa)\"\r\n    'f.StopIfTrue = False\r\n\r\n  Next c\r\nNext r\r\n\r\nEnd Sub\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Sub CellsCondition() &#8216; \u6761\u4ef6\u4ed8\u66f8\u5f0f\u30af\u30ea\u30a2 Set w = Sheets(&#8220;11\u6708&#8221;) &#8216;w.Cells.FormatConditions.Delete w.Columns(&#8220;J&#8221;).FormatCo &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=1999\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;VBA \u6761\u4ef6\u4ed8\u304d\u66f8\u5f0f&#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-1999","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\/1999","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=1999"}],"version-history":[{"count":7,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/1999\/revisions"}],"predecessor-version":[{"id":5444,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/1999\/revisions\/5444"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}