{"id":2545,"date":"2024-05-16T18:20:53","date_gmt":"2024-05-16T09:20:53","guid":{"rendered":"http:\/\/oreoreki.gotdns.ch\/?p=2545"},"modified":"2024-05-16T19:17:17","modified_gmt":"2024-05-16T10:17:17","slug":"%e3%80%90%e6%95%b0c%e3%80%91excelvba%e3%81%a7%e8%a1%8c%e5%88%97%e3%81%a7%e3%81%a7%e3%81%8d%e3%82%8b%e4%b8%8d%e5%ae%9a%e6%96%b9%e7%a8%8b%e5%bc%8f%e3%81%ae%e8%a7%a3%e6%b3%95%e3%80%90%e3%82%86%e3%81%a3","status":"publish","type":"post","link":"http:\/\/oreoreki.gotdns.ch\/?p=2545","title":{"rendered":"\u3010\u6570C\u3011ExcelVBA\u3067\u884c\u5217\u3067\u3067\u304d\u308b\u4e0d\u5b9a\u65b9\u7a0b\u5f0f\u306e\u89e3\u6cd5\u3010\u3086\u3063\u304f\u308a\u89e3\u8aac\u3011"},"content":{"rendered":"<p><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"750\" height=\"422\" src=\"https:\/\/www.youtube.com\/embed\/A7HpTbtEEH4?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=ja&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span><\/p>\n<div class=\"hcb_wrap\">\n<p>ExcelVBA\u3067\u884c\u5217\u3067\u3067\u304d\u308b\u4e0d\u5b9a\u65b9\u7a0b\u5f0f\u306e\u89e3\u6cd5\u30de\u30af\u30ed\u3092\u4f5c\u308b<br \/>\n<span class=\"bold-red\">\u3053\u306e\u52d5\u753b\u306e\u30de\u30af\u30ed\u306fWindows11\/Office2016\u3067\u4f5c\u6210\u3057\u3066\u307e\u3059\u3002<br \/>\n<\/span><\/p>\n<p>\u4e0d\u5b9a\u65b9\u7a0b\u5f0f\u306e\u89e3\u6cd5\u30de\u30af\u30ed<br \/>\nExcel  <a href=\"http:\/\/tamajimu.sytes.net\/wp-content\/uploads\/2024\/05\/futei.xlsm\">futei.xlsm<\/a><br \/>\nGoogle <a href=\"https:\/\/docs.google.com\/spreadsheets\/d\/1Wc6-vRcb556zUakg5UtBrW0UB6mr6hHArclTIP_CXxg\/edit?usp=sharing\">\u4e0d\u5b9a\u65b9\u7a0b\u5f0f\u3092\u89e3\u3044\u3066\u307f\u308b<\/a><\/p>\n<h2><\/h2>\n<pre class=\"prism line-numbers lang-ts\" data-lang=\"TypeScript\"><code>Sub macro()\r\n    a = 23\r\n    b = 31\r\n    c = 1\r\n\r\n    kai = tokutei(a, b)\r\n    \r\n    Debug.Print \"\u89e3  x= \"; kai(1, 1) * c, \"  y= \"; kai(1, 2) * c\r\nEnd Sub\r\n\r\nFunction tokutei(a, b)\r\n    rt = \"\"\r\n    \r\n    'a,b\u306e\u7b26\u53f7\u3092\u6b63\u306b\u3059\u308b\r\n    m_norm = Evaluate(\"{\" &amp; Sgn(a) &amp; \",0;0,\" &amp; Sgn(b) &amp; \"}\")\r\n    \r\n    v = Evaluate(\"{\" &amp; a &amp; \";\" &amp; b &amp; \"}\")   'a\u3068b\u306e\u5217\u30d9\u30af\u30c8\u30eb\r\n    \r\n    v = WorksheetFunction.MMult(m_norm, v)\r\n    \r\n    Do\r\n        r = Int(v(1, 1) \/ v(2, 1))\r\n        q = v(1, 1) Mod v(2, 1)\r\n        If q = 0 Then\r\n            '\u5272\u308a\u5207\u308c\u305f\r\n            Debug.Print \"\u30e6\u30fc\u30af\u30ea\u30c3\u30c9\u306e\u4e92\u9664\u6cd50\"\r\n            Debug.Print \"|\" &amp; Right(\"    \" &amp; v(1, 1), 4); \"| = |\"; Right(\"    \" &amp; r, 4); \"  0 ||\" &amp; Right(\"    \" &amp; v(2, 1), 4); \" |\"\r\n            Debug.Print \"|\" &amp; Right(\"    \" &amp; v(2, 1), 4); \"|   |   0 -1 ||\"; Right(\"     \" &amp; q, 4); \" |\"\r\n            Debug.Print \"\u6700\u5927\u516c\u7d04\u6570GCM\", v(2, 1)\r\n            rt = r &amp; \",\" &amp; rt\r\n            Exit Do\r\n        Else\r\n            Debug.Print \"\u30e6\u30fc\u30af\u30ea\u30c3\u30c9\u306e\u4e92\u9664\u6cd51\"\r\n            Debug.Print \"|\" &amp; Right(\"    \" &amp; v(1, 1), 4); \"| = |\"; Right(\"    \" &amp; r, 4); \"  0 ||\" &amp; Right(\"    \" &amp; v(2, 1), 4); \" |\"\r\n            Debug.Print \"|\" &amp; Right(\"    \" &amp; v(2, 1), 4); \"|   |   0 -1 ||\"; Right(\"     \" &amp; q, 4); \" |\"\r\n            Debug.Print\r\n            \r\n            v(1, 1) = v(2, 1)\r\n            v(2, 1) = q\r\n            If rt = \"\" Then\r\n                rt = r\r\n            Else\r\n                rt = r &amp; \",\" &amp; rt\r\n            End If\r\n        End If\r\n        DoEvents\r\n    Loop\r\n    \r\n    Debug.Print \"\u5546\u306e\u4e26\u3073  \", rt\r\n    r = Split(rt, \",\")\r\n    \r\n    p = [{1,0;0,1}] '\u5358\u4f4d\u884c\u5217\r\n    \r\n    For i = 0 To UBound(r) + 1\r\n        '\u9006\u884c\u5217\u3092\u304b\u3051\u3066\u3044\u304f\r\n        \r\n        If i &gt; UBound(r) Then\r\n            s = m_norm\r\n        Else\r\n            s = Evaluate(\"{0,1;1,-\" &amp; r(i) &amp; \"}\")\r\n        End If\r\n        p0 = WorksheetFunction.MMult(p, s)\r\n        Debug.Print \"|\" &amp; Right(\"    \" &amp; p(1, 1), 4); \"  \"; Right(\"    \" &amp; p(1, 2), 4); \"| * |\" &amp; Right(\"    \" &amp; s(1, 1), 4); \"  \"; Right(\"    \" &amp; s(1, 2), 4); \"| = |\" &amp; Right(\"    \" &amp; p0(1, 1), 4); \"  \"; Right(\"    \" &amp; p0(1, 2), 4); \"|\"\r\n        Debug.Print \"|\" &amp; Right(\"    \" &amp; p(2, 1), 4); \"  \"; Right(\"    \" &amp; p(2, 2), 4); \"|   |\" &amp; Right(\"    \" &amp; s(2, 1), 4); \"  \"; Right(\"    \" &amp; s(2, 2), 4); \"|   |\" &amp; Right(\"    \" &amp; p0(2, 1), 4); \"  \"; Right(\"    \" &amp; p0(2, 2), 4); \"|\"\r\n        Debug.Print\r\n        p = p0\r\n        DoEvents\r\n    Next\r\n\r\n    tokutei = p\r\nEnd Function\r\n<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>ExcelVBA\u3067\u884c\u5217\u3067\u3067\u304d\u308b\u4e0d\u5b9a\u65b9\u7a0b\u5f0f\u306e\u89e3\u6cd5\u30de\u30af\u30ed\u3092\u4f5c\u308b \u3053\u306e\u52d5\u753b\u306e\u30de\u30af\u30ed\u306fWindows11\/O [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2546,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[34],"tags":[],"class_list":["post-2545","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vba"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"http:\/\/oreoreki.gotdns.ch\/wp-content\/uploads\/sites\/2\/2024\/05\/cexcelvba.jpg","jetpack_shortlink":"https:\/\/wp.me\/p9WqRX-F3","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts\/2545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2545"}],"version-history":[{"count":4,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts\/2545\/revisions"}],"predecessor-version":[{"id":2550,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/posts\/2545\/revisions\/2550"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=\/wp\/v2\/media\/2546"}],"wp:attachment":[{"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2545"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/oreoreki.gotdns.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}