{"id":581,"date":"2025-03-12T00:33:34","date_gmt":"2025-03-11T15:33:34","guid":{"rendered":"https:\/\/hajidai.com\/excel\/2025\/03\/%e3%80%90excel%e4%b8%8a%e7%b4%9a%e8%80%85%e5%bf%85%e8%a6%8b%e3%80%91vba%e3%81%a7%e3%83%9e%e3%82%a4%e3%82%af%e3%83%ad%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9%e9%80%a3%e6%90%ba%ef%bc%81%e6%a5%ad%e5%8b%99\/"},"modified":"2025-03-12T00:33:34","modified_gmt":"2025-03-11T15:33:34","slug":"%e3%80%90excel%e4%b8%8a%e7%b4%9a%e8%80%85%e5%bf%85%e8%a6%8b%e3%80%91vba%e3%81%a7%e3%83%9e%e3%82%a4%e3%82%af%e3%83%ad%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9%e9%80%a3%e6%90%ba%ef%bc%81%e6%a5%ad%e5%8b%99","status":"publish","type":"post","link":"https:\/\/hajidai.com\/excel\/2025\/03\/%e3%80%90excel%e4%b8%8a%e7%b4%9a%e8%80%85%e5%bf%85%e8%a6%8b%e3%80%91vba%e3%81%a7%e3%83%9e%e3%82%a4%e3%82%af%e3%83%ad%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9%e9%80%a3%e6%90%ba%ef%bc%81%e6%a5%ad%e5%8b%99\/","title":{"rendered":"\u3010Excel\u4e0a\u7d1a\u8005\u5fc5\u898b\u3011VBA\u3067\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u9023\u643a\uff01\u696d\u52d9\u52b9\u7387\u3092\u5287\u7684\u306b\u5411\u4e0a\u3055\u305b\u308b\u5b9f\u8df5\u30c6\u30af\u30cb\u30c3\u30af"},"content":{"rendered":"<h2>\u4e0a\u7d1a\u8005\u304c\u5b9f\u73fe\u3059\u308bVBA\u306b\u3088\u308b\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u9023\u643a<\/h2>\n<p>\u307e\u305a\u3001Excel\u3092\u4f7f\u3044\u3053\u306a\u3057\u3066\u3082\u3063\u3068\u697d\u3092\u3057\u305f\u3044\u3001\u696d\u52d9\u3092\u52b9\u7387\u5316\u3057\u305f\u3044\u4eba\u304c\u3059\u3050\u306b\u8a66\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u30de\u30af\u30ed\u30b3\u30fc\u30c9\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>&#8220;`vba<br \/>\nSub AutomaticDataImport()<br \/>\n    Dim ws As Worksheet<br \/>\n    Dim lastRow As Long<\/p>\n<p>    Set ws = ThisWorkbook.Sheets(&#8220;\u30c7\u30fc\u30bf\u53d6\u8fbc&#8221;)<br \/>\n    lastRow = ws.Cells(ws.Rows.Count, &#8220;A&#8221;).End(xlUp).Row<\/p>\n<p>    With ws.QueryTables.Add(Connection:=&#8221;URL;https:\/\/api.example.com\/data&#8221;, Destination:=ws.Range(&#8220;A&#8221; &#038; lastRow + 1))<br \/>\n        .Name = &#8220;API\u30c7\u30fc\u30bf\u53d6\u8fbc&#8221;<br \/>\n        .FieldNames = True<br \/>\n        .RowNumbers = False<br \/>\n        .FillAdjacentFormulas = False<br \/>\n        .PreserveFormatting = True<br \/>\n        .RefreshOnFileOpen = False<br \/>\n        .BackgroundQuery = True<br \/>\n        .RefreshStyle = xlInsertDeleteCells<br \/>\n        .SavePassword = False<br \/>\n        .SaveData = True<br \/>\n        .AdjustColumnWidth = True<br \/>\n        .RefreshPeriod = 0<br \/>\n        .WebSelectionType = xlEntirePage<br \/>\n        .WebFormatting = xlWebFormattingNone<br \/>\n        .WebPreFormattedTextToColumns = True<br \/>\n        .WebConsecutiveDelimitersAsOne = True<br \/>\n        .WebSingleBlockTextImport = False<br \/>\n        .WebDisableDateRecognition = False<br \/>\n        .WebDisableRedirections = False<br \/>\n        .Refresh BackgroundQuery:=False<br \/>\n    End With<br \/>\nEnd Sub<br \/>\n&#8220;`<\/p>\n<p>\u3053\u306e\u30de\u30af\u30ed\u306f\u3001\u5916\u90e8API\u304b\u3089\u30c7\u30fc\u30bf\u3092\u81ea\u52d5\u7684\u306b\u53d6\u308a\u8fbc\u3080\u3082\u306e\u3067\u3059\u3002Excel \u30de\u30af\u30ed\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u5b9a\u671f\u7684\u306a\u30c7\u30fc\u30bf\u66f4\u65b0\u4f5c\u696d\u3092\u5927\u5e45\u306b\u52b9\u7387\u5316\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>1. VBA\u3068\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u306e\u878d\u5408<\/h3>\n<p>VBA\uff08Visual Basic for Applications\uff09\u306f\u3001Excel\u5185\u3067\u52d5\u4f5c\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u3059\u3002\u4e00\u65b9\u3001\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u3068\u306f\u3001\u5927\u898f\u6a21\u306a\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u5c0f\u3055\u306a\u72ec\u7acb\u3057\u305f\u30b5\u30fc\u30d3\u30b9\u306b\u5206\u5272\u3059\u308b\u8a2d\u8a08\u624b\u6cd5\u3067\u3059\u3002\u3053\u308c\u3089\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001Excel\u306e\u6a5f\u80fd\u3092\u5927\u5e45\u306b\u62e1\u5f35\u3057\u3001\u5916\u90e8\u30b5\u30fc\u30d3\u30b9\u3068\u306e\u9023\u643a\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u793e\u5185\u306e\u5728\u5eab\u7ba1\u7406\u30b7\u30b9\u30c6\u30e0\u3084CRM\uff08\u9867\u5ba2\u95a2\u4fc2\u7ba1\u7406\uff09\u30c4\u30fc\u30eb\u3068Excel\u3092\u9023\u643a\u3055\u305b\u308b\u3053\u3068\u3067\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306e\u30c7\u30fc\u30bf\u66f4\u65b0\u3084\u5206\u6790\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u610f\u601d\u6c7a\u5b9a\u306e\u30b9\u30d4\u30fc\u30c9\u304c\u5411\u4e0a\u3057\u3001\u696d\u52d9\u52b9\u7387\u304c\u5927\u5e45\u306b\u6539\u5584\u3055\u308c\u307e\u3059\u3002<\/p>\n<h3>2. API\u3092\u6d3b\u7528\u3057\u305f\u30c7\u30fc\u30bf\u9023\u643a<\/h3>\n<p>API\uff08Application Programming Interface\uff09\u306f\u3001\u7570\u306a\u308b\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u9593\u3067\u30c7\u30fc\u30bf\u3092\u3084\u308a\u53d6\u308a\u3059\u308b\u305f\u3081\u306e\u4ed5\u7d44\u307f\u3067\u3059\u3002VBA\u3092\u4f7f\u3063\u3066API\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u3067\u3001\u5916\u90e8\u30b5\u30fc\u30d3\u30b9\u306e\u30c7\u30fc\u30bf\u3092Excel\u306b\u53d6\u308a\u8fbc\u3093\u3060\u308a\u3001Excel\u306e\u30c7\u30fc\u30bf\u3092\u5916\u90e8\u30b5\u30fc\u30d3\u30b9\u306b\u9001\u4fe1\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u5177\u4f53\u7684\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u6d3b\u7528\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\uff1a<\/p>\n<p>&#8211; \u682a\u4fa1\u3084\u70ba\u66ff\u30ec\u30fc\u30c8\u306a\u3069\u306e\u91d1\u878d\u30c7\u30fc\u30bf\u3092\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u53d6\u5f97\u3057\u3001\u81ea\u52d5\u66f4\u65b0\u3059\u308b<br \/>\n&#8211; \u6c17\u8c61\u60c5\u5831\u3092\u53d6\u5f97\u3057\u3001\u8ca9\u58f2\u4e88\u6e2c\u3084\u5728\u5eab\u7ba1\u7406\u306b\u6d3b\u7528\u3059\u308b<br \/>\n&#8211; \u793e\u5185\u306e\u4ed6\u30b7\u30b9\u30c6\u30e0\u3068\u30c7\u30fc\u30bf\u3092\u9023\u643a\u3057\u3001\u7d71\u5408\u7684\u306a\u5206\u6790\u3092\u884c\u3046<\/p>\n<p>\u3053\u308c\u3089\u306e\u9023\u643a\u306b\u3088\u308a\u3001\u624b\u4f5c\u696d\u3067\u306e\u30c7\u30fc\u30bf\u5165\u529b\u3084\u30b3\u30d4\u30fc&#038;\u30da\u30fc\u30b9\u30c8\u306e\u624b\u9593\u3092\u5927\u5e45\u306b\u524a\u6e1b\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>3. \u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0<\/h3>\n<p>\u5916\u90e8\u30b5\u30fc\u30d3\u30b9\u3068\u306e\u9023\u643a\u3092\u884c\u3046\u969b\u306f\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3068\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u306b\u7279\u306b\u6ce8\u610f\u3092\u6255\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002API\u30ad\u30fc\u3084\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3069\u306e\u8a8d\u8a3c\u60c5\u5831\u306f\u3001\u9069\u5207\u306b\u6697\u53f7\u5316\u3057\u3066\u7ba1\u7406\u3057\u307e\u3057\u3087\u3046\u3002\u307e\u305f\u3001\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u63a5\u7d9a\u306e\u554f\u984c\u3084API\u306e\u4ed5\u69d8\u5909\u66f4\u306a\u3069\u306b\u5099\u3048\u3066\u3001\u9069\u5207\u306a\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306f\u3001\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3092\u542b\u3080VBA\u30b3\u30fc\u30c9\u306e\u4f8b\u3067\u3059\uff1a<\/p>\n<p>&#8220;`vba<br \/>\nSub SecureAPICall()<br \/>\n    On Error GoTo ErrorHandler<\/p>\n<p>    &#8216; API\u30ad\u30fc\u3092\u6697\u53f7\u5316\u3057\u3066\u4fdd\u5b58\u3059\u308b\u4f8b<br \/>\n    Dim encryptedKey As String<br \/>\n    encryptedKey = EncryptString(&#8220;your_api_key_here&#8221;)<\/p>\n<p>    &#8216; API\u3092\u547c\u3073\u51fa\u3059\u51e6\u7406<br \/>\n    &#8216; &#8230;<\/p>\n<p>    Exit Sub<\/p>\n<p>ErrorHandler:<br \/>\n    MsgBox &#8220;\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f: &#8221; &#038; Err.Description<br \/>\n    &#8216; \u30a8\u30e9\u30fc\u30ed\u30b0\u3092\u8a18\u9332\u3059\u308b\u306a\u3069\u306e\u51e6\u7406\u3092\u8ffd\u52a0<br \/>\nEnd Sub<\/p>\n<p>Function EncryptString(text As String) As String<br \/>\n    &#8216; \u7c21\u6613\u7684\u306a\u6697\u53f7\u5316\u51e6\u7406\uff08\u5b9f\u969b\u306f\u3088\u308a\u5f37\u529b\u306a\u65b9\u6cd5\u3092\u4f7f\u7528\uff09<br \/>\n    EncryptString = StrReverse(text)<br \/>\nEnd Function<br \/>\n&#8220;`<\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3068\u9069\u5207\u306a\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u5bfe\u7b56\u3092\u884c\u3046\u3053\u3068\u3067\u3001\u3088\u308a\u5b89\u5168\u3067\u4fe1\u983c\u6027\u306e\u9ad8\u3044Excel \u30de\u30af\u30ed\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0a\u306e3\u3064\u306e\u30dd\u30a4\u30f3\u30c8\u3092\u62bc\u3055\u3048\u308b\u3053\u3068\u3067\u3001VBA\u3092\u6d3b\u7528\u3057\u305f\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u9023\u643a\u3092\u52b9\u679c\u7684\u306b\u5b9f\u73fe\u3057\u3001Excel\u3092\u5358\u306a\u308b\u8868\u8a08\u7b97\u30bd\u30d5\u30c8\u304b\u3089\u5f37\u529b\u306a\u30d3\u30b8\u30cd\u30b9\u30c4\u30fc\u30eb\u3078\u3068\u9032\u5316\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u3089\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u6d3b\u7528\u3057\u3066\u3001\u696d\u52d9\u52b9\u7387\u5316\u3068\u751f\u7523\u6027\u5411\u4e0a\u3092\u76ee\u6307\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u7d1a\u8005\u304c\u5b9f\u73fe\u3059\u308bVBA\u306b\u3088\u308b\u30de\u30a4\u30af\u30ed\u30b5\u30fc\u30d3\u30b9\u9023\u643a \u307e\u305a\u3001Excel\u3092\u4f7f\u3044\u3053\u306a\u3057\u3066\u3082\u3063\u3068\u697d\u3092\u3057\u305f\u3044\u3001\u696d\u52d9\u3092\u52b9\u7387\u5316\u3057\u305f\u3044\u4eba\u304c\u3059\u3050\u306b\u8a66\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u30de\u30af\u30ed\u30b3\u30fc\u30c9\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002 #8220;`vba Sub Automatic<\/p>\n","protected":false},"author":2,"featured_media":580,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-581","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-advanced"],"_links":{"self":[{"href":"https:\/\/hajidai.com\/excel\/wp-json\/wp\/v2\/posts\/581","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hajidai.com\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hajidai.com\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hajidai.com\/excel\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hajidai.com\/excel\/wp-json\/wp\/v2\/comments?post=581"}],"version-history":[{"count":0,"href":"https:\/\/hajidai.com\/excel\/wp-json\/wp\/v2\/posts\/581\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hajidai.com\/excel\/wp-json\/wp\/v2\/media\/580"}],"wp:attachment":[{"href":"https:\/\/hajidai.com\/excel\/wp-json\/wp\/v2\/media?parent=581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hajidai.com\/excel\/wp-json\/wp\/v2\/categories?post=581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hajidai.com\/excel\/wp-json\/wp\/v2\/tags?post=581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}