{"id":3879,"date":"2023-01-05T12:00:03","date_gmt":"2023-01-05T03:00:03","guid":{"rendered":"https:\/\/www.bold.ne.jp\/engineer-club\/?p=3879"},"modified":"2025-11-19T10:51:33","modified_gmt":"2025-11-19T01:51:33","slug":"vba-format","status":"publish","type":"post","link":"https:\/\/www.bold.ne.jp\/engineer-club\/vba-format","title":{"rendered":"VBA\u306eformat\u95a2\u6570\u3068\u306f\uff1f\u6307\u5b9a\u3057\u305f\u66f8\u5f0f\u306b\u5f93\u3063\u3066String\u578b\u306b\u5909\u63db\u3059\u308bformat\u95a2\u6570\u3092\u89e3\u8aac"},"content":{"rendered":"<p>\u300c<span>20220101<\/span>\u300d\u306e\u3088\u3046\u306a\u6587\u5b57\u5217\u3092\u3001\u300c<span>2022\/01\/01<\/span>\u300d\u306e\u3088\u3046\u306b\u5909\u63db\u3057\u305f\u3044\u3068\u601d\u3063\u305f\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u304b\uff1fformat\u95a2\u6570\u3067\u306f\u3001\u300c<span>2022\/01\/01<\/span>\u300d\u3084\u300c\u4ee4\u548c<span>4<\/span>\u5e74<span>1<\/span>\u6708<span>1<\/span>\u65e5\u300d\u306e\u3088\u3046\u306b\u5909\u63db\u3067\u304d\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001\u65e5\u4ed8\u3068\u6642\u523b\u306e\u8868\u793a\u8a2d\u5b9a\u3092\u30e1\u30a4\u30f3\u306b\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#VBAformat\">\uff11\uff0eVBA\u306eformat\u95a2\u6570\u306b\u3064\u3044\u3066<\/a><ul><li><a href=\"#-format\">\uff11-\uff11\uff0eformat\u95a2\u6570\u3068\u306f<\/a><\/li><li><a href=\"#-format-2\">\uff11-\uff12\uff0eformat\u95a2\u6570\u306e\u69cb\u6587<\/a><\/li><\/ul><\/li><li><a href=\"#VBA_format\">\uff12\uff0eVBA format\u95a2\u6570\u306e\u4f7f\u7528\u4f8b<\/a><ul><li><a href=\"#i\">\uff12-\uff11\uff0e\u57fa\u672c\u7684\u306a\u4f7f\u7528\u4f8b<\/a><\/li><li><a href=\"#i-2\">\uff12-\uff12\uff0e\u7279\u6b8a\u306a\u66f8\u304d\u65b9\u3092\u3059\u308b\u5834\u5408<\/a><\/li><\/ul><\/li><li><a href=\"#i-3\">\uff13\uff0e\u6700\u5f8c\u306b<\/a><\/li><\/ul><\/div>\n<h2><span id=\"VBAformat\">\uff11\uff0eVBA\u306eformat\u95a2\u6570\u306b\u3064\u3044\u3066<\/span><\/h2>\n<h3><span id=\"-format\"><span>\uff11-\uff11\uff0eformat<\/span>\u95a2\u6570\u3068\u306f<\/span><\/h3>\n<p><span>format<\/span>\u95a2\u6570\u3068\u306f\u3001<strong><\/strong><span class=\"f-marker-p\"><strong>\u6307\u5b9a\u3057\u305f\u66f8\u5f0f\u306b\u5f93\u3063\u3066String\u578b\u306b\u5909\u63db\u3059\u308b\u95a2\u6570<\/strong><\/span>\u3067\u3059\u3002\u4e3b\u306b\u6570\u5b57\u306e\u6587\u5b57\u5217\u3092\u3001\u5e74\u6708\u65e5\u3084\u6642\u5206\u79d2\u306e\u3088\u3046\u306b\u5909\u63db\u3059\u308b\u969b\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<h3><span id=\"-format-2\">\uff11-\uff12\uff0e<span>format<\/span>\u95a2\u6570\u306e\u69cb\u6587<\/span><\/h3>\n<p><span>Format([<\/span>\u5909\u63db\u3057\u305f\u3044\u6587\u5b57\u5217<span>], [<\/span>\u6307\u5b9a\u3059\u308b\u66f8\u5f0f<span>])<br \/>\n<\/span>\u5909\u63db\u3057\u305f\u3044\u6587\u5b57\u5217\uff1a\u5909\u63db\u3057\u305f\u3044\u6587\u5b57\u5217\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<br \/>\n\u6307\u5b9a\u3059\u308b\u66f8\u5f0f\uff1a\u4ee5\u4e0b\u306e\u4f7f\u7528\u4f8b\u3067\u8aac\u660e\u3059\u308b\u66f8\u5f0f\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u8aac\u660e\u3057\u305f\u66f8\u5f0f\u4ee5\u5916\u306b\u3082\u591a\u304f\u306e\u66f8\u5f0f\u304c\u5b58\u5728\u3057\u307e\u3059\u3002<\/p>\n<h2><span id=\"VBA_format\"><span>\uff12\uff0eVBA format<\/span>\u95a2\u6570\u306e\u4f7f\u7528\u4f8b<\/span><\/h2>\n<h3><span id=\"i\">\uff12-\uff11\uff0e\u57fa\u672c\u7684\u306a\u4f7f\u7528\u4f8b<\/span><\/h3>\n<h4>\uff12-\uff11-\uff11\uff0e\u5b9a\u7fa9\u6e08\u307f\u306e\u66f8\u5f0f<\/h4>\n<p>\u5b9a\u7fa9\u6e08\u307f\u306e\u66f8\u5f0f\u306b\u306f\u4e0b\u8a18\u306e<span>6<\/span>\u7a2e\u985e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<table style=\"border-collapse: collapse; width: 100%; height: 167px;\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 17.6413%; height: 24px;\">\u66f8\u5f0f\u540d<\/td>\n<td style=\"width: 82.3587%; height: 24px;\">\u8aac\u660e<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 17.6413%; height: 24px;\">Long Date<\/td>\n<td style=\"width: 82.3587%; height: 24px;\">\u30b7\u30b9\u30c6\u30e0\u65e5\u4ed8\u306e<span class=\"f-marker-p\">\u9577\u3044\u65e5\u4ed8\u5f62\u5f0f\u306e\u66f8\u5f0f<\/span>\u306b\u5f93\u3063\u3066\u65e5\u4ed8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"width: 17.6413%; height: 23px;\">Medium Date<\/td>\n<td style=\"width: 82.3587%; height: 23px;\">\u30db\u30b9\u30c8\u306e\u8a00\u8a9e\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3001<span class=\"f-marker-p\">\u4e2d\u9593\u306e\u9577\u3055\u306e\u65e5\u4ed8\u66f8\u5f0f<\/span>\u3092\u4f7f\u7528\u3057\u3066\u65e5\u4ed8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 17.6413%; height: 24px;\">Short Date<\/td>\n<td style=\"width: 82.3587%; height: 24px;\">\u30b7\u30b9\u30c6\u30e0\u306e<span class=\"f-marker-p\">\u77ed\u3044\u65e5\u4ed8\u66f8\u5f0f<\/span>\u3092\u4f7f\u7528\u3057\u3066\u65e5\u4ed8\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 17.6413%; height: 24px;\">Long Time<\/td>\n<td style=\"width: 82.3587%; height: 24px;\">\u30b7\u30b9\u30c6\u30e0\u306e<span class=\"f-marker-p\">\u9577\u3044\u6642\u9593\u5f62\u5f0f<\/span>\u3092\u4f7f\u7528\u3057\u3066\u6642\u9593\u3092\u8868\u793a\u3057\u307e\u3059\u3002\u6642\u9593\u3001\u5206\u3001\u79d2\u304c\u542b\u307e\u308c\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 17.6413%; height: 24px;\">Medium Time<\/td>\n<td style=\"width: 82.3587%; height: 24px;\">\u6642\u9593\u3068\u5206\u3092\u3001<span class=\"f-marker-p\">12\u6642\u9593\u306e\u66f8\u5f0f\u3068 \u5348\u524d\/\u5348\u5f8c<\/span>\u3092\u4f7f\u7528\u3057\u3066\u8868\u793a\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 17.6413%; height: 24px;\">Short Time<\/td>\n<td style=\"width: 82.3587%; height: 24px;\"><span class=\"f-marker-p\">24\u6642\u9593\u306e\u5f62\u5f0f<\/span>\u3092\u4f7f\u7528\u3057\u3066\u6642\u9593\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre class=\"prettyprint lang:default decode:true\">Sub sample01()\r\n    Dim val As String\r\n    Dim str As String\r\n\r\n    str = \"2022\/12\/31 10:20:30\"\r\n    val = \"General Date = \" &amp; Format(str, \"General Date\") &amp; vbCrLf &amp; _\r\n          \"Long Date    = \" &amp; Format(str, \"Long Date\") &amp; vbCrLf &amp; _\r\n          \"Medium Date  = \" &amp; Format(str, \"Medium Date\") &amp; vbCrLf &amp; _\r\n          \"Short Date   = \" &amp; Format(str, \"Short Date\") &amp; vbCrLf &amp; _\r\n          \"Long Time    = \" &amp; Format(str, \"Long Time\") &amp; vbCrLf &amp; _\r\n          \"Medium Time  = \" &amp; Format(str, \"Medium Time\") &amp; vbCrLf &amp; _\r\n          \"Short Time   = \" &amp; Format(str, \"Short Time\")\r\nMsgBox val\r\n\r\nEnd Sub<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<p><a href=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2023\/01\/\u5b9f\u884c\u7d50\u679c1.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2023\/01\/\u5b9f\u884c\u7d50\u679c1.png\" alt=\"\u5b9f\u884c\u7d50\u679c1\" width=\"288\" height=\"300\" class=\"alignnone size-full wp-image-3881\" \/><\/a><\/p>\n<h4>\uff12-\uff11-\uff12\uff0e\u30e6\u30fc\u30b6\u30fc\u304c\u5b9a\u7fa9\u3059\u308b\u5834\u5408\u306e\u6307\u5b9a\u6587\u5b57<\/h4>\n<p>\u901a\u5e38\u306f\u3001\u8907\u6570\u306e\u6307\u5b9a\u6587\u5b57\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002\u65e5\u4ed8\u3092\u8868\u793a\u3059\u308b\u306e\u306b\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8868\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">Sub sample02()\r\n    Dim val As String\r\n    Dim str As String\r\n\r\n    str = \"2022-1-2 1:02:03\"\r\n    val = Format(str, \"yyyy\/mm\/dd\") &amp; vbCrLf &amp; _\r\n          Format(str, \"yy\/m\/d\") &amp; vbCrLf &amp; _\r\n          Format(str, \"dddddd\") &amp; vbCrLf &amp; _\r\n          Format(str, \"ge\/mm\/dd\") &amp; vbCrLf &amp; _\r\n          Format(str, \"ggee\/m\/dd\") &amp; vbCrLf &amp; _\r\n          Format(str, \"gggee\u5e74mm\u6708dd\u65e5\")\r\n\r\nMsgBox val<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<p><a href=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2023\/01\/\u5b9f\u884c\u7d50\u679c2.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2023\/01\/\u5b9f\u884c\u7d50\u679c2.png\" alt=\"\u5b9f\u884c\u7d50\u679c2\" width=\"176\" height=\"281\" class=\"alignnone size-full wp-image-3882\" \/><\/a><\/p>\n<h3><span id=\"i-2\">\uff12-\uff12\uff0e\u7279\u6b8a\u306a\u66f8\u304d\u65b9\u3092\u3059\u308b\u5834\u5408<\/span><\/h3>\n<h4>\uff12-\uff12-\uff11\uff0e\u5927\u6587\u5b57\uff0f\u5c0f\u6587\u5b57\u306b\u5909\u63db\u3059\u308b\u5834\u5408<\/h4>\n<p>\u6307\u5b9a\u3057\u305f\u6587\u5b57\u5217\u5185\u306e\u3059\u3079\u3066\u3092\u5909\u63db\u3057\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">Sub sample04()\r\n    Dim val As String\r\n    Dim str As String\r\n\r\n    val = \"\u5c0f\u6587\u5b57\u2192\u5927\u6587\u5b57 = \" &amp; Format(\"format\", \"&gt;&amp;&amp;&amp;&amp;&amp;&amp;\") &amp; vbCrLf &amp; _\r\n          \"\u5927\u6587\u5b57\u2192\u5c0f\u6587\u5b57 = \" &amp; Format(\"FORMAT\", \"&lt;&amp;&amp;&amp;&amp;&amp;&amp;\") &amp; vbCrLf &amp; _\r\n          \"\u4e00\u90e8\u304c\u5927\u6587\u5b57\u2192\u3059\u3079\u3066\u5927\u6587\u5b57 = \" &amp; Format(\"Format\", \"&gt;&amp;&amp;&amp;&amp;&amp;&amp;\")\r\n\r\n    MsgBox val\r\n\r\nEnd Sub<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<p><a href=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2023\/01\/\u5b9f\u884c\u7d50\u679c3.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2023\/01\/\u5b9f\u884c\u7d50\u679c3.png\" alt=\"\u5b9f\u884c\u7d50\u679c3\" width=\"302\" height=\"224\" class=\"alignnone size-full wp-image-3883\" \/><\/a><\/p>\n<h4>\uff12-\uff12-\uff12\uff0e\u5909\u63db\u3067\u304d\u306a\u3044\u5834\u5408<\/h4>\n<p>\u5909\u63db\u3067\u304d\u306a\u3044\u6587\u5b57\u5217\u3092\u6307\u5b9a\u3057\u305f\u5834\u5408\u306f\u3001\u5909\u63db\u524d\u306e\u6587\u5b57\u5217\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"prettyprint lang:default decode:true\">Sub sample05()\r\n    Dim val As String\r\n    Dim str As String\r\n\r\n    val = \"\u5b58\u5728\u3057\u306a\u3044\u65e5\u4ed8 = \" &amp; Format(\"9999-99-99\", \"General Date\") &amp; vbCrLf &amp; _\r\n          \"\u5168\u89d2\u6587\u5b57\u3092\u5c0f\u6587\u5b57\u2192\u5927\u6587\u5b57 = \" &amp; Format(\"\uff46\uff4f\uff52\uff4d\uff41\uff54\", \"&gt;&amp;&amp;&amp;&amp;&amp;&amp;\")\r\n\r\n    MsgBox val\r\n\r\nEnd Sub<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<p><a href=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2023\/01\/\u5b9f\u884c\u7d50\u679c4.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2023\/01\/\u5b9f\u884c\u7d50\u679c4.png\" alt=\"\u5b9f\u884c\u7d50\u679c4\" width=\"326\" height=\"205\" class=\"alignnone size-full wp-image-3884\" srcset=\"https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2023\/01\/\u5b9f\u884c\u7d50\u679c4.png 326w, https:\/\/www.bold.ne.jp\/engineer-club\/wp-content\/uploads\/2023\/01\/\u5b9f\u884c\u7d50\u679c4-300x190.png 300w\" sizes=\"(max-width: 326px) 100vw, 326px\" \/><\/a><\/p>\n<h2><span id=\"i-3\">\uff13\uff0e\u6700\u5f8c\u306b<\/span><\/h2>\n<p><span>format<\/span>\u95a2\u6570\u306e\u7b2c<span>2<\/span>\u5f15\u6570\u306b\u306f\u3001\u4e0a\u8a18\u4ee5\u5916\u306b\u3082\u591a\u304f\u306e\u6307\u5b9a\u6587\u5b57\u304c\u3042\u308a\u307e\u3059\u3002\u7528\u9014\u306b\u5408\u308f\u305b\u3066\u3001\u7d44\u307f\u5408\u308f\u305b\u305f\u308a\u8abf\u3079\u305f\u308a\u3057\u3066\u6d3b\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u300c20220101\u300d\u306e\u3088\u3046\u306a\u6587\u5b57\u5217\u3092\u3001\u300c2022\/01\/01\u300d\u306e\u3088\u3046\u306b\u5909\u63db\u3057\u305f\u3044\u3068\u601d\u3063\u305f\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u304b\uff1fformat\u95a2\u6570\u3067\u306f\u3001\u300c2022\/01\/01\u300d\u3084\u300c\u4ee4\u548c4\u5e741\u67081\u65e5\u300d\u306e\u3088\u3046\u306b\u5909\u63db\u3067\u304d\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001\u65e5\u4ed8\u3068\u6642\u523b\u306e [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":3886,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/3879"}],"collection":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/comments?post=3879"}],"version-history":[{"count":8,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/3879\/revisions"}],"predecessor-version":[{"id":6115,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/posts\/3879\/revisions\/6115"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media\/3886"}],"wp:attachment":[{"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/media?parent=3879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bold.ne.jp\/engineer-club\/wp-json\/wp\/v2\/categories?post=3879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}