{"id":18378,"date":"2026-07-19T03:14:00","date_gmt":"2026-07-18T18:14:00","guid":{"rendered":"https:\/\/genai-ai.co.jp\/ai-kanri\/?p=18378"},"modified":"2026-07-19T03:14:00","modified_gmt":"2026-07-18T18:14:00","slug":"cc-vba-error-1004","status":"publish","type":"post","link":"https:\/\/genai-ai.co.jp\/ai-kanri\/blog\/cc-vba-error-1004\/","title":{"rendered":"\u30102026\u5e747\u6708\u6700\u65b0\u3011VBA\u5b9f\u884c\u6642\u30a8\u30e9\u30fc1004\u306e\u539f\u56e0\u3068\u89e3\u6c7a\u65b9\u6cd5\u5b8c\u5168\u30ac\u30a4\u30c9\uff5c\u767a\u751f\u30d1\u30bf\u30fc\u30f3\u5225\u306e\u5bfe\u51e6\u6cd5\u3092\u5b9f\u8df5\u30b3\u30fc\u30c9\u4ed8\u304d\u3067\u89e3\u8aac"},"content":{"rendered":"\n<style>\n.g-flow-row{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;align-items:center;}\n.g-flow-item{background:linear-gradient(135deg,#1a1a1a,#2a1015);color:#fff;border-radius:8px;padding:16px 14px;min-width:130px;flex:1;text-align:center;}\n.g-flow-arrow{color:#dc2626;font-size:20px;font-weight:700;}\n.g-card-row{display:flex;gap:12px;flex-wrap:wrap;margin:0 0 32px;}\n.g-card-row>div{flex:1;min-width:220px;}\n@media(max-width:600px){\n  .g-flow-row{flex-direction:column;}\n  .g-flow-arrow{transform:rotate(90deg);}\n  .g-card-row{flex-direction:column;}\n  .g-card-row>div{min-width:100%;}\n}\n<\/style>\n\n\n\n<div style=\"margin:0 0 32px;\">\n  <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/07\/thumb-cc-vba-error-1004.jpg\" alt=\"\u30102026\u5e747\u6708\u6700\u65b0\u3011VBA\u5b9f\u884c\u6642\u30a8\u30e9\u30fc1004\u306e\u539f\u56e0\u3068\u89e3\u6c7a\u65b9\u6cd5\u5b8c\u5168\u30ac\u30a4\u30c9\uff5c\u767a\u751f\u30d1\u30bf\u30fc\u30f3\u5225\u306e\u5bfe\u51e6\u6cd5\u3092\u5b9f\u8df5\u30b3\u30fc\u30c9\u4ed8\u304d\u3067\u89e3\u8aac\" style=\"width:100%;height:auto;border-radius:12px;display:block;\">\n<\/div>\n\n\n\n<div style=\"background:#f8f9fa;border-radius:12px;padding:24px 28px;margin:0 0 32px;border-left:4px solid #dc2626;\">\n  <p style=\"font-size:15px;font-weight:700;color:#1a1a1a;margin:0 0 16px;\">\u3053\u306e\u8a18\u4e8b\u306e\u5185\u5bb9<\/p>\n  <ol style=\"margin:0;padding-left:20px;font-size:14px;line-height:2.2;list-style:none;\">\n    <li><a href=\"#sec-01\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#dc2626;font-weight:700;margin-right:8px;\">01<\/span>\u30a8\u30e9\u30fc1004\u3068\u306f\u4f55\u304b\u30fb\u306a\u305c\u6700\u983b\u51fa\u306a\u306e\u304b<\/a><\/li>\n    <li><a href=\"#sec-02\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#dc2626;font-weight:700;margin-right:8px;\">02<\/span>\u539f\u56e01\uff1a\u5b58\u5728\u3057\u306a\u3044\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3053\u3046\u3068\u3057\u305f<\/a><\/li>\n    <li><a href=\"#sec-03\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#dc2626;font-weight:700;margin-right:8px;\">03<\/span>\u539f\u56e02\uff1a\u5b58\u5728\u3057\u306a\u3044\u30b7\u30fc\u30c8\u30fb\u30bb\u30eb\u7bc4\u56f2\u3092\u6307\u5b9a\u3057\u305f<\/a><\/li>\n    <li><a href=\"#sec-04\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#dc2626;font-weight:700;margin-right:8px;\">04<\/span>\u539f\u56e03\uff1a\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306e\u30bb\u30eb\u3092Select\u3057\u3088\u3046\u3068\u3057\u305f<\/a><\/li>\n    <li><a href=\"#sec-05\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#dc2626;font-weight:700;margin-right:8px;\">05<\/span>\u539f\u56e04\uff1a\u30b3\u30d4\u30fc\u5143\u3068\u30b3\u30d4\u30fc\u5148\u306e\u7bc4\u56f2\u304c\u7570\u306a\u308b<\/a><\/li>\n    <li><a href=\"#sec-06\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#dc2626;font-weight:700;margin-right:8px;\">06<\/span>\u539f\u56e05\uff1a\u4fdd\u8b77\u3055\u308c\u305f\u30b7\u30fc\u30c8\u306b\u66f8\u304d\u8fbc\u3082\u3046\u3068\u3057\u305f<\/a><\/li>\n    <li><a href=\"#sec-07\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#dc2626;font-weight:700;margin-right:8px;\">07<\/span>\u539f\u56e06\uff1a\u540d\u524d\u4ed8\u304d\u7bc4\u56f2\u30fb\u30c6\u30fc\u30d6\u30eb\u306e\u6307\u5b9a\u30df\u30b9<\/a><\/li>\n    <li><a href=\"#sec-08\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#dc2626;font-weight:700;margin-right:8px;\">08<\/span>\u539f\u56e07\uff1a\u884c\u30fb\u5217\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304c0\u4ee5\u4e0b\u307e\u305f\u306f\u4e0a\u9650\u8d85<\/a><\/li>\n    <li><a href=\"#sec-09\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#dc2626;font-weight:700;margin-right:8px;\">09<\/span>\u30c7\u30d0\u30c3\u30b0\u624b\u6cd5\uff08Debug.Print\u30fb\u30d6\u30ec\u30fc\u30af\u30dd\u30a4\u30f3\u30c8\u30fb\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\uff09<\/a><\/li>\n    <li><a href=\"#sec-10\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#dc2626;font-weight:700;margin-right:8px;\">10<\/span>\u30a8\u30e9\u30fc\u51e6\u7406\u3067Error 1004\u3092\u30ad\u30e3\u30c3\u30c1\u3059\u308b<\/a><\/li>\n    <li><a href=\"#sec-11\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#dc2626;font-weight:700;margin-right:8px;\">11<\/span>\u307e\u3068\u3081<\/a><\/li>\n    <li><a href=\"#faq\" style=\"color:#495057;text-decoration:none;\"><span style=\"color:#dc2626;font-weight:700;margin-right:8px;\">FAQ<\/span>\u3088\u304f\u3042\u308b\u8cea\u554f<\/a><\/li>\n  <\/ol>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">VBA\u30de\u30af\u30ed\u3092\u4f5c\u3063\u3066\u3044\u308b\u3068\u3001\u5fc5\u305a\u3068\u8a00\u3063\u3066\u3044\u3044\u307b\u3069\u906d\u9047\u3059\u308b\u306e\u304c\u300c\u5b9f\u884c\u6642\u30a8\u30e9\u30fc '1004' Application-defined or object-defined error\u300d\u3067\u3059\u3002\u3053\u306e\u30a8\u30e9\u30fc\u306f\u300c\u7279\u5b9a\u306e1\u3064\u306e\u539f\u56e0\u300d\u3067\u306f\u306a\u304f\u3001\u300cExcel\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30e2\u30c7\u30eb\u3078\u306e\u4e0d\u6b63\u306a\u64cd\u4f5c\u5168\u822c\u300d\u3092\u6307\u3057\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u540c\u3058\u30a8\u30e9\u30fc\u756a\u53f7\u3067\u3082\u539f\u56e0\u304c\u307e\u3063\u305f\u304f\u7570\u306a\u308b\u30b1\u30fc\u30b9\u304c\u591a\u304f\u3001\u521d\u5fc3\u8005\u306b\u3068\u3063\u3066\u7279\u306b\u89e3\u6c7a\u304c\u96e3\u3057\u3044\u30a8\u30e9\u30fc\u3068\u3057\u3066\u77e5\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3059\u308b7\u3064\u306e\u4e3b\u8981\u30d1\u30bf\u30fc\u30f3\u3092\u539f\u56e0\u30fb\u75c7\u72b6\u30fb\u89e3\u6c7a\u30b3\u30fc\u30c9\u4ed8\u304d\u3067\u5fb9\u5e95\u89e3\u8aac\u3057\u307e\u3059\u3002\u300c\u30d5\u30a1\u30a4\u30eb\u672a\u5b58\u5728\u300d\u300c\u30b7\u30fc\u30c8\u672a\u5b58\u5728\u300d\u300c\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306eSelect\u300d\u300c\u30b3\u30d4\u30fc\u7bc4\u56f2\u4e0d\u4e00\u81f4\u300d\u300c\u4fdd\u8b77\u30b7\u30fc\u30c8\u300d\u300c\u540d\u524d\u4ed8\u304d\u7bc4\u56f2\u300d\u300c\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u8d85\u904e\u300d\u2014\u2014\u305d\u308c\u305e\u308c\u306e\u539f\u56e0\u3092\u7406\u89e3\u3057\u3066\u6b63\u3057\u304f\u5bfe\u51e6\u3059\u308b\u3053\u3068\u3067\u3001\u30a8\u30e9\u30fc1004\u306b\u60a9\u3080\u6642\u9593\u3092\u30bc\u30ed\u306b\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"balloon-wrap\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/ceo-sugasawa.jpg\" alt=\"\u4ee3\u8868\u83c5\u6fa4\">\n    <span class=\"balloon-name\">\u4ee3\u8868\u83c5\u6fa4<\/span>\n  <\/div>\n  <div class=\"balloon-body\">\u5f0a\u793e\u306e\u7d4c\u9a13\u4e0a\u3001VBA\u306e\u30a8\u30e9\u30fc\u76f8\u8ac7\u306e\u4e2d\u3067\u6700\u3082\u591a\u3044\u306e\u304c\u3053\u306e1004\u30a8\u30e9\u30fc\u3067\u3059\u3002\u300c\u306a\u305c1004\u306a\u306e\u304b\u308f\u304b\u3089\u306a\u3044\u300d\u3068\u3044\u3046\u58f0\u3092\u3088\u304f\u805e\u304d\u307e\u3059\u304c\u3001\u305d\u308c\u306f\u30a8\u30e9\u30fc\u756a\u53f7\u304c\u540c\u3058\u3067\u3082\u539f\u56e0\u304c7\u7a2e\u985e\u4ee5\u4e0a\u3042\u308b\u305f\u3081\u3067\u3059\u3002\u3053\u306e\u8a18\u4e8b\u306e\u30d1\u30bf\u30fc\u30f3\u5225\u30c1\u30a7\u30c3\u30af\u30ea\u30b9\u30c8\u3092\u4f7f\u3048\u3070\u3001\u307b\u3068\u3093\u3069\u306e\u30b1\u30fc\u30b9\u3067\u539f\u56e0\u306e\u7279\u5b9a\u3068\u89e3\u6c7a\u304c\u3067\u304d\u307e\u3059\u3002<\/div>\n<\/div>\n\n\n\n<div style=\"background:#fafafa;border-radius:8px;padding:16px 20px;margin:16px 0;border-left:4px solid #dc2626;\">\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u30a8\u30e9\u30fc1004\u306e\u6b63\u4f53<\/strong>\uff1a\u306a\u305c\u300cApplication-defined or object-defined error\u300d\u3068\u3044\u3046\u6c4e\u7528\u30e1\u30c3\u30bb\u30fc\u30b8\u306b\u306a\u308b\u306e\u304b<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>7\u3064\u306e\u767a\u751f\u30d1\u30bf\u30fc\u30f3<\/strong>\uff1a\u30d5\u30a1\u30a4\u30eb\u30fb\u30b7\u30fc\u30c8\u30fbSelect\u30fb\u30b3\u30d4\u30fc\u30fb\u4fdd\u8b77\u30fb\u540d\u524d\u4ed8\u304d\u7bc4\u56f2\u30fb\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u5404\u539f\u56e0<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>Dir\u95a2\u6570\u306b\u3088\u308b\u30d5\u30a1\u30a4\u30eb\u5b58\u5728\u78ba\u8a8d<\/strong>\uff1a\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\u524d\u306e\u5b89\u5168\u306a\u78ba\u8a8d\u65b9\u6cd5<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306eSelect\u554f\u984c<\/strong>\uff1aSelect\u3092\u4f7f\u308f\u306a\u3044\u300c\u5024\u6e21\u3057\u300d\u3078\u306e\u66f8\u304d\u63db\u3048\u30d1\u30bf\u30fc\u30f3<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>DisplayAlerts\u30d7\u30ed\u30d1\u30c6\u30a3<\/strong>\uff1a\u78ba\u8a8d\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u5236\u5fa1\u3057\u3066\u30a8\u30e9\u30fc\u3092\u9632\u3050\u65b9\u6cd5<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>Debug.Print\u30fb\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6<\/strong>\uff1a\u5909\u6570\u306e\u5024\u3092\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u78ba\u8a8d\u3059\u308b\u30c7\u30d0\u30c3\u30b0\u6280\u8853<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>On Error GoTo\u30671004\u3092\u30ad\u30e3\u30c3\u30c1<\/strong>\uff1a\u539f\u56e0\u5225\u306b\u5206\u5c90\u3059\u308b\u30a8\u30e9\u30fc\u51e6\u7406\u306e\u5b9f\u88c5\u30d1\u30bf\u30fc\u30f3<\/span><\/div>\n\n<\/div>\n\n\n<div style=\"margin:48px 0 8px;display:flex;gap:12px;justify-content:center;flex-wrap:wrap;\"><a href=\"https:\/\/aikanri.genai-ai.co.jp\/seminar2-blog\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_content=cc-vba-error-1004&#038;blog_slug=cc-vba-error-1004\" target=\"_blank\" rel=\"noopener\" aria-label=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff08\u7121\u6599\u30fb1on1\u30fb60\u5206\uff09\u306e\u4e88\u7d04\u753b\u9762\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_seminar_claude_code_2026.jpg\" alt=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff5c\u7d4c\u55b6\u8005\u30fb\u4f1a\u793e\u5f79\u54e1\u5c02\u7528 1on1 60\u5206 \u7121\u6599\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_campaign=cc-vba-error-1004&#038;utm_content=h2-banner-kanri\" target=\"_blank\" rel=\"noopener\" aria-label=\"AI\u9b3c\u7ba1\u7406 \u516c\u5f0f\u30b5\u30a4\u30c8\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_blog_1to1.jpg\" alt=\"Claude Code\u3092\u7d4c\u55b6\u306b\u6d3b\u304b\u3057\u305f\u3044\u65b9\u3078 \u2014 AI\u9b3c\u7ba1\u7406\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><\/div>\n\n\n<div id=\"sec-01\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">01<\/span>\n  <span class=\"section-label\" style=\"display:block;\">ERROR 1004<\/span>\n  <span class=\"section-title\" style=\"display:block;\">\u30a8\u30e9\u30fc1004\u3068\u306f\u4f55\u304b\u30fb\u306a\u305c\u6700\u983b\u51fa\u306a\u306e\u304b<\/span>\n  <span class=\"section-desc\">Application-defined or object-defined error\u306e\u6b63\u4f53\u3068\u767a\u751f\u30e1\u30ab\u30cb\u30ba\u30e0<\/span>\n<\/h2>\n\n\n\n<div style=\"background:#f8f9fa;border-left:4px solid #6b7280;border-radius:0 8px 8px 0;padding:16px 20px;margin:20px 0;\">\n  <p style=\"margin:0 0 4px;font-size:13px;font-weight:700;color:#6b7280;letter-spacing:1px;\">&#128218; \u7528\u8a9e\u89e3\u8aac<\/p>\n  <p style=\"margin:0;font-size:15px;line-height:1.7;\"><strong>\u5b9f\u884c\u6642\u30a8\u30e9\u30fc1004\uff08Application-defined or object-defined error\uff09<\/strong>\uff1aVBA\u306eExcel\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30e2\u30c7\u30eb\u306b\u5bfe\u3057\u3066\u300c\u5b9f\u884c\u3067\u304d\u306a\u3044\u64cd\u4f5c\u300d\u3092\u884c\u3063\u305f\u3068\u304d\u306b\u767a\u751f\u3059\u308b\u6c4e\u7528\u30a8\u30e9\u30fc\u3002\u756a\u53f7\u304c1004\u3068\u56fa\u5b9a\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u300c\u3069\u3093\u306a\u64cd\u4f5c\u304c\u539f\u56e0\u304b\u300d\u306f\u30e1\u30c3\u30bb\u30fc\u30b8\u3060\u3051\u3067\u306f\u7279\u5b9a\u3067\u304d\u307e\u305b\u3093\u3002\u30d5\u30a1\u30a4\u30eb\u64cd\u4f5c\u30fb\u30b7\u30fc\u30c8\u64cd\u4f5c\u30fb\u30bb\u30eb\u64cd\u4f5c\u30fb\u30b3\u30d4\u30fc\u64cd\u4f5c\u30fb\u4fdd\u8b77\u89e3\u9664\u306a\u3069\u3001Excel\u304c\u53d7\u3051\u4ed8\u3051\u3089\u308c\u306a\u3044\u72b6\u614b\u306e\u64cd\u4f5c\u5168\u822c\u304c\u3053\u306e\u30a8\u30e9\u30fc\u3092\u5f15\u304d\u8d77\u3053\u3057\u307e\u3059\u3002<\/p>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u300c\u5b9f\u884c\u6642\u30a8\u30e9\u30fc '1004'\u300d\u306f\u3001Excel\u306eVBA\u30a8\u30e9\u30fc\u306e\u4e2d\u3067\u6700\u3082\u767a\u751f\u4ef6\u6570\u304c\u591a\u3044\u30a8\u30e9\u30fc\u3067\u3059\u3002\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u300cApplication-defined or object-defined error\uff08\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5b9a\u7fa9\u307e\u305f\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5b9a\u7fa9\u306e\u30a8\u30e9\u30fc\uff09\u300d\u3068\u3044\u3046\u6c4e\u7528\u7684\u306a\u6587\u8a00\u306e\u305f\u3081\u3001\u300c\u4f55\u304c\u60aa\u3044\u306e\u304b\u308f\u304b\u3089\u306a\u3044\u300d\u3068\u3044\u3046\u72b6\u6cc1\u306b\u9665\u308a\u3084\u3059\u3044\u306e\u304c\u7279\u5fb4\u3067\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u30a8\u30e9\u30fc1004\u304c\u6c4e\u7528\u30e1\u30c3\u30bb\u30fc\u30b8\u306b\u306a\u308b\u306e\u306f\u3001\u3053\u306e\u30a8\u30e9\u30fc\u304c\u300c1\u3064\u306e\u539f\u56e0\u300d\u3067\u306f\u306a\u304f\u300cExcel\u304c\u51e6\u7406\u3092\u62d2\u5426\u3057\u305f\u5834\u5408\u306e\u7dcf\u79f0\u300d\u3068\u3057\u3066\u8a2d\u8a08\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3067\u3059\u3002\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u72b6\u6cc1\uff08\u3069\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3093\u3060\u304b\u30fb\u3069\u3093\u306a\u5f15\u6570\u3092\u6e21\u3057\u305f\u304b\uff09\u306b\u3088\u3063\u3066\u539f\u56e0\u3092\u7279\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<table>\n<thead><tr><th>\u767a\u751f\u30d1\u30bf\u30fc\u30f3<\/th><th>\u5178\u578b\u7684\u306a\u30b3\u30fc\u30c9<\/th><th>\u6839\u672c\u539f\u56e0<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>\u30d5\u30a1\u30a4\u30eb\u672a\u5b58\u5728<\/td><td>Workbooks.Open(filePath)<\/td><td>\u6307\u5b9a\u30d1\u30b9\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u306a\u3044<\/td><\/tr>\n<tr><td>\u30b7\u30fc\u30c8\u672a\u5b58\u5728<\/td><td>Sheets(\"\u30c7\u30fc\u30bf\").Select<\/td><td>\u6307\u5b9a\u540d\u306e\u30b7\u30fc\u30c8\u304c\u5b58\u5728\u3057\u306a\u3044<\/td><\/tr>\n<tr><td>\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306eSelect<\/td><td>ws.Cells(1,1).Select\uff08ws\u304c\u975e\u30a2\u30af\u30c6\u30a3\u30d6\uff09<\/td><td>Select\/Activate\u306f\u73fe\u5728\u8868\u793a\u4e2d\u306e\u30b7\u30fc\u30c8\u306b\u3057\u304b\u4f7f\u3048\u306a\u3044<\/td><\/tr>\n<tr><td>\u30b3\u30d4\u30fc\u7bc4\u56f2\u4e0d\u4e00\u81f4<\/td><td>ws.Paste\uff08\u30b3\u30d4\u30fc\u5143\u3068\u5f62\u304c\u9055\u3046\uff09<\/td><td>\u30b3\u30d4\u30fc\u5143\u306e\u5f62\u72b6\u3068\u30da\u30fc\u30b9\u30c8\u5148\u306e\u5f62\u72b6\u304c\u5408\u308f\u306a\u3044<\/td><\/tr>\n<tr><td>\u4fdd\u8b77\u30b7\u30fc\u30c8\u3078\u306e\u66f8\u304d\u8fbc\u307f<\/td><td>ws.Cells(1,1).Value = \"x\"\uff08\u4fdd\u8b77\u4e2d\uff09<\/td><td>\u30b7\u30fc\u30c8\u304c\u4fdd\u8b77\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u5024\u5909\u66f4\u4e0d\u53ef<\/td><\/tr>\n<tr><td>\u540d\u524d\u4ed8\u304d\u7bc4\u56f2\u306e\u8aa4\u6307\u5b9a<\/td><td>Range(\"SalesData\")<\/td><td>\u540d\u524d\u304c\u5b58\u5728\u3057\u306a\u3044\u30fb\u5225\u30d6\u30c3\u30af\u306e\u540d\u524d\u3092\u53c2\u7167\u3057\u305f<\/td><\/tr>\n<tr><td>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u7bc4\u56f2\u8d85\u904e<\/td><td>Cells(0, 1)\u307e\u305f\u306fCells(1048577, 1)<\/td><td>\u884c\/\u5217\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304c0\u4ee5\u4e0b\u304b\u4e0a\u9650\u3092\u8d85\u3048\u3066\u3044\u308b<\/td><\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<div class=\"g-flow-row\" style=\"margin:24px 0;\">\n  <div class=\"g-flow-item\"><strong>VBA\u30b3\u30fc\u30c9\u304c<br>Excel\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u64cd\u4f5c<\/strong><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>Excel\u304c\u64cd\u4f5c\u3092<br>\u53d7\u3051\u4ed8\u3051\u3089\u308c\u306a\u3044\u72b6\u614b<\/strong><br><span style=\"font-size:12px;\">\u30d5\u30a1\u30a4\u30eb\u672a\u5b58\u5728\/\u4fdd\u8b77\/\u7bc4\u56f2\u5916\u7b49<\/span><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u30a8\u30e9\u30fc1004<br>\u304c\u767a\u751f<\/strong><br><span style=\"font-size:12px;\">Application-defined...<\/span><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u539f\u56e0\u30d1\u30bf\u30fc\u30f3\u3092<br>\u7279\u5b9a\u3057\u3066\u5bfe\u51e6<\/strong><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u6b63\u5e38\u52d5\u4f5c\u306b<br>\u4fee\u6b63\u5b8c\u4e86<\/strong><\/div>\n<\/div>\n\n\n\n<div class=\"balloon-wrap is-right\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/yamazaki-avatar.png\" alt=\"AI\u9b3c\u7ba1\u7406\u5c71\u5d0e\">\n    <span class=\"balloon-name\">AI\u9b3c\u7ba1\u7406\u5c71\u5d0e<\/span>\n  <\/div>\n  <div class=\"balloon-body\">\u30a8\u30e9\u30fc1004\u304c\u51fa\u305f\u3068\u304d\u306e\u6700\u521d\u306e\u78ba\u8a8d\u30dd\u30a4\u30f3\u30c8\u306f\u300c\u3069\u306e\u884c\u3067\u6b62\u307e\u3063\u3066\u3044\u308b\u304b\u300d\u3067\u3059\u3002VBA\u30a8\u30c7\u30a3\u30bf\u306e\u30c7\u30d0\u30c3\u30b0\u30e2\u30fc\u30c9\uff08Ctrl+F5\u3067\u306a\u304fF5\u3067\u5b9f\u884c\uff09\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u3068\u3001\u554f\u984c\u306e\u884c\u304c\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u307e\u3059\u3002\u305d\u306e\u884c\u3067\u300c\u4f55\u306e\u64cd\u4f5c\u3092\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\u304b\u300d\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3067\u30017\u3064\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u3069\u308c\u306b\u8a72\u5f53\u3059\u308b\u304b\u304c\u7d5e\u308a\u8fbc\u3081\u307e\u3059\u3002<\/div>\n<\/div>\n\n\n\n<div style=\"background:#f0fdf4;border:1px solid #22c55e;border-radius:8px;padding:20px 24px;margin:24px 0;\">\n  <div style=\"display:flex;align-items:center;gap:8px;margin-bottom:12px;\">\n    <span style=\"font-size:18px;\">&#128161;<\/span>\n    <strong style=\"color:#16a34a;font-size:15px;\">\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u884c\u3092\u7279\u5b9a\u3059\u308b\u306b\u306f<\/strong>\n  <\/div>\n  <p style=\"margin:0;font-size:15px;line-height:1.8;color:#333;\">VBA\u30a8\u30c7\u30a3\u30bf\u3067\u300c\u5b9f\u884c\u300d\u2192\u300c\u30b9\u30c6\u30c3\u30d7\u30a4\u30f3\uff08F8\uff09\u300d\u30671\u884c\u305a\u3064\u5b9f\u884c\u3059\u308b\u3068\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u6b63\u78ba\u306a\u884c\u3067\u6b62\u307e\u308a\u307e\u3059\u3002\u307e\u305f\u306f\u901a\u5e38\u5b9f\u884c\uff08F5\uff09\u3067\u30a8\u30e9\u30fc\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u51fa\u305f\u3068\u304d\u300c\u30c7\u30d0\u30c3\u30b0\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u30a8\u30e9\u30fc\u767a\u751f\u884c\u304c\u9ec4\u8272\u304f\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u307e\u3059\u3002<\/p>\n<\/div>\n\n\n<div style=\"margin:48px 0 8px;display:flex;gap:12px;justify-content:center;flex-wrap:wrap;\"><a href=\"https:\/\/aikanri.genai-ai.co.jp\/seminar2-blog\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_content=cc-vba-error-1004&#038;blog_slug=cc-vba-error-1004\" target=\"_blank\" rel=\"noopener\" aria-label=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff08\u7121\u6599\u30fb1on1\u30fb60\u5206\uff09\u306e\u4e88\u7d04\u753b\u9762\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_seminar_claude_code_2026.jpg\" alt=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff5c\u7d4c\u55b6\u8005\u30fb\u4f1a\u793e\u5f79\u54e1\u5c02\u7528 1on1 60\u5206 \u7121\u6599\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_campaign=cc-vba-error-1004&#038;utm_content=h2-banner-kanri\" target=\"_blank\" rel=\"noopener\" aria-label=\"AI\u9b3c\u7ba1\u7406 \u516c\u5f0f\u30b5\u30a4\u30c8\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_blog_1to1.jpg\" alt=\"Claude Code\u3092\u7d4c\u55b6\u306b\u6d3b\u304b\u3057\u305f\u3044\u65b9\u3078 \u2014 AI\u9b3c\u7ba1\u7406\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><\/div>\n\n\n<div id=\"sec-02\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">02<\/span>\n  <span class=\"section-label\" style=\"display:block;\">CAUSE 1: FILE NOT FOUND<\/span>\n  <span class=\"section-title\" style=\"display:block;\">\u539f\u56e01\uff1a\u5b58\u5728\u3057\u306a\u3044\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3053\u3046\u3068\u3057\u305f<\/span>\n  <span class=\"section-desc\">Dir\u95a2\u6570\u3067\u4e8b\u524d\u78ba\u8a8d\u30fb\u30d1\u30b9\u6587\u5b57\u5217\u306e\u30c7\u30d0\u30c3\u30b0\u65b9\u6cd5<\/span>\n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u30a8\u30e9\u30fc1004\u306e\u6700\u3082\u5206\u304b\u308a\u3084\u3059\u3044\u539f\u56e0\u306e1\u3064\u304c\u300cWorkbooks.Open\u3067\u5b58\u5728\u3057\u306a\u3044\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u3092\u6307\u5b9a\u3057\u305f\u300d\u30b1\u30fc\u30b9\u3067\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u306e\u6307\u5b9a\u30df\u30b9\u30fb\u30d5\u30a1\u30a4\u30eb\u304c\u79fb\u52d5\u30fb\u524a\u9664\u30fb\u5225\u30d5\u30a9\u30eb\u30c0\u306b\u4fdd\u5b58\u2014\u2014\u3053\u3046\u3057\u305f\u72b6\u6cc1\u3067Workbooks.Open\u3092\u5b9f\u884c\u3059\u308b\u3068\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u306a\u304a\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f\u30a8\u30e9\u30fc\u756a\u53f753\uff08File not found\uff09\u304c\u51fa\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u30d1\u30b9\u306e\u554f\u984c\u306b\u3088\u3063\u3066\u306f1004\u304c\u51fa\u308b\u30b1\u30fc\u30b9\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#fef2f2;border:2px solid #dc2626;border-radius:8px;padding:20px 24px;margin:24px 0;\">\n  <div style=\"display:flex;align-items:center;gap:8px;margin-bottom:12px;\">\n    <span style=\"font-size:20px;\">&#9888;&#65039;<\/span>\n    <strong style=\"color:#dc2626;font-size:16px;\">\u30d1\u30b9\u306e\u30b3\u30d4\u30da\u30df\u30b9\u304c\u6700\u591a\u539f\u56e0<\/strong>\n  <\/div>\n  <p style=\"margin:0;font-size:15px;line-height:1.8;color:#333;\">\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u306e\u30a8\u30e9\u30fc\u306e\u591a\u304f\u306f\u300c\u30d0\u30c3\u30af\u30b9\u30e9\u30c3\u30b7\u30e5\u306e\u5165\u308c\u5fd8\u308c\u300d\u300c\u30d5\u30a9\u30eb\u30c0\u540d\u306e\u5927\u6587\u5b57\u5c0f\u6587\u5b57\u300d\u300c\u5168\u89d2\u6587\u5b57\u306e\u6df7\u5165\u300d\u300c\u672b\u5c3e\u306e\u30b9\u30da\u30fc\u30b9\u300d\u3068\u3044\u3063\u305f\u5358\u7d14\u306a\u30df\u30b9\u3067\u3059\u3002\u307e\u305aDebug.Print\u3067\u30d1\u30b9\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3092\u7fd2\u6163\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">2-1. Dir\u95a2\u6570\u3067\u30d5\u30a1\u30a4\u30eb\u306e\u5b58\u5728\u3092\u4e8b\u524d\u78ba\u8a8d\u3059\u308b<\/h3>\n\n\n\n<div style=\"background:#f8f9fa;border-left:4px solid #6b7280;border-radius:0 8px 8px 0;padding:16px 20px;margin:20px 0;\">\n  <p style=\"margin:0 0 4px;font-size:13px;font-weight:700;color:#6b7280;letter-spacing:1px;\">&#128218; \u7528\u8a9e\u89e3\u8aac<\/p>\n  <p style=\"margin:0;font-size:15px;line-height:1.7;\"><strong>Dir\u95a2\u6570<\/strong>\uff1aVBA\u306e\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u3002\u6307\u5b9a\u3057\u305f\u30d1\u30b9\u306e\u30d5\u30a1\u30a4\u30eb\u307e\u305f\u306f\u30d5\u30a9\u30eb\u30c0\u304c\u5b58\u5728\u3059\u308b\u304b\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002Dir(\u30d1\u30b9)\u3092\u547c\u3073\u51fa\u3057\u3066\u7a7a\u6587\u5b57\uff08\"\"\uff09\u304c\u8fd4\u3063\u3066\u304f\u308c\u3070\u30d5\u30a1\u30a4\u30eb\u306a\u3057\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u304c\u8fd4\u3063\u3066\u304f\u308c\u3070\u5b58\u5728\u3057\u307e\u3059\u3002\u30ef\u30a4\u30eb\u30c9\u30ab\u30fc\u30c9\uff08*\uff09\u3082\u4f7f\u7528\u53ef\u80fd\u3002Workbooks.Open\u306e\u524d\u306bDir\u95a2\u6570\u3067\u5b58\u5728\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3067\u30a8\u30e9\u30fc1004\u3092\u672a\u7136\u306b\u9632\u3052\u307e\u3059\u3002<\/p>\n<\/div>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; Dir\u95a2\u6570\u3067\u30d5\u30a1\u30a4\u30eb\u5b58\u5728\u78ba\u8a8d\u3057\u3066\u304b\u3089Open\u3059\u308b\uff08\u63a8\u5968\u30d1\u30bf\u30fc\u30f3\uff09\nSub SafeOpenWorkbook()\n    Dim filePath As String\n    filePath = &quot;C:\\Users\\kohei\\Desktop\\report.xlsx&quot;\n\n    &#x27; \u2460 \u307e\u305aDir\u95a2\u6570\u3067\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3059\u308b\u304b\u78ba\u8a8d\n    If Dir(filePath) = &quot;&quot; Then\n        MsgBox &quot;\u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002&quot; &amp; vbCrLf &amp; _\n               &quot;\u30d1\u30b9: &quot; &amp; filePath &amp; vbCrLf &amp; _\n               &quot;\u30d5\u30a1\u30a4\u30eb\u304c\u6b63\u3057\u3044\u30d5\u30a9\u30eb\u30c0\u306b\u3042\u308b\u304b\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;, _\n               vbExclamation, &quot;\u30d5\u30a1\u30a4\u30eb\u672a\u5b58\u5728&quot;\n        Exit Sub\n    End If\n\n    &#x27; \u2461 \u5b58\u5728\u304c\u78ba\u8a8d\u3067\u304d\u305f\u3089\u958b\u304f\uff08\u30a8\u30e9\u30fc1004\u304c\u51fa\u306a\u3044\uff09\n    Dim wb As Workbook\n    Set wb = Workbooks.Open(filePath)\n\n    &#x27; \u51e6\u7406\n    MsgBox &quot;\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304d\u307e\u3057\u305f: &quot; &amp; wb.Name\n    wb.Close False\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">2-2. Debug.Print\u3067\u30d1\u30b9\u3092\u78ba\u8a8d\u3059\u308b<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u300c\u30d5\u30a1\u30a4\u30eb\u306f\u78ba\u304b\u306b\u3042\u308b\u306e\u306b\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u300d\u3068\u3044\u3046\u5834\u5408\u3001\u30d1\u30b9\u5909\u6570\u306e\u5024\u304c\u610f\u56f3\u3068\u9055\u3063\u3066\u3044\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u3093\u306a\u3068\u304d\u306fDebug.Print\u3067\u30d1\u30b9\u5909\u6570\u306e\u5b9f\u969b\u306e\u5024\u3092\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\u306b\u51fa\u529b\u3057\u3066\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; Debug.Print\u3067\u30d1\u30b9\u306e\u5185\u5bb9\u3092\u78ba\u8a8d\u3059\u308b\nSub DebugFilePath()\n    Dim folderPath As String\n    Dim fileName As String\n    Dim filePath As String\n\n    folderPath = &quot;C:\\Users\\kohei\\Desktop\\&quot;\n    fileName = &quot;report.xlsx&quot;\n    filePath = folderPath &amp; fileName\n\n    &#x27; \u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\uff08Ctrl+G\uff09\u306b\u51fa\u529b\u3057\u3066\u78ba\u8a8d\n    Debug.Print &quot;folderPath: [&quot; &amp; folderPath &amp; &quot;]&quot;  &#x27; \u672b\u5c3e\u306e\\\u78ba\u8a8d\n    Debug.Print &quot;fileName: [&quot; &amp; fileName &amp; &quot;]&quot;       &#x27; \u5168\u89d2\u6587\u5b57\u30fb\u30b9\u30da\u30fc\u30b9\u78ba\u8a8d\n    Debug.Print &quot;filePath: [&quot; &amp; filePath &amp; &quot;]&quot;       &#x27; \u7d50\u5408\u5f8c\u306e\u78ba\u8a8d\n\n    &#x27; Dir\u95a2\u6570\u3067\u5b58\u5728\u78ba\u8a8d\n    Debug.Print &quot;Dir result: [&quot; &amp; Dir(filePath) &amp; &quot;]&quot;  &#x27; &quot;&quot; \u306a\u3089\u5b58\u5728\u3057\u306a\u3044\n\n    If Dir(filePath) = &quot;&quot; Then\n        MsgBox &quot;\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u307e\u305b\u3093: &quot; &amp; filePath\n        Exit Sub\n    End If\n\n    Workbooks.Open filePath\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<div style=\"background:#f8f9fa;border-left:4px solid #6b7280;border-radius:0 8px 8px 0;padding:16px 20px;margin:20px 0;\">\n  <p style=\"margin:0 0 4px;font-size:13px;font-weight:700;color:#6b7280;letter-spacing:1px;\">&#128218; \u7528\u8a9e\u89e3\u8aac<\/p>\n  <p style=\"margin:0;font-size:15px;line-height:1.7;\"><strong>\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6<\/strong>\uff1aVBA\u30a8\u30c7\u30a3\u30bf\u4e0b\u90e8\u306b\u8868\u793a\u3055\u308c\u308b\u30c7\u30d0\u30c3\u30b0\u7528\u30a6\u30a3\u30f3\u30c9\u30a6\u3002Debug.Print\u6587\u3067\u51fa\u529b\u3057\u305f\u5024\u304c\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u8868\u793a\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306fCtrl+G\uff08\u307e\u305f\u306f\u30e1\u30cb\u30e5\u30fc\u300c\u8868\u793a\u300d\u2192\u300c\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\u300d\uff09\u3067\u958b\u3051\u307e\u3059\u3002\u5909\u6570\u306e\u5024\u78ba\u8a8d\u30fb\u30d1\u30b9\u306e\u5185\u5bb9\u78ba\u8a8d\u30fb\u8a08\u7b97\u7d50\u679c\u306e\u78ba\u8a8d\u306a\u3069\u3001\u30c7\u30d0\u30c3\u30b0\u4f5c\u696d\u5168\u822c\u306b\u4f7f\u3044\u307e\u3059\u3002\u5b9f\u884c\u4e2d\u306f\u3082\u3061\u308d\u3093\u3001\u505c\u6b62\u4e2d\uff08\u30d6\u30ec\u30fc\u30af\u30dd\u30a4\u30f3\u30c8\u6642\uff09\u3082?\u5909\u6570\u540d\u3068\u5165\u529b\u3057\u3066\u5909\u6570\u306e\u73fe\u5728\u5024\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">2-3. \u3088\u304f\u3042\u308b\u30d1\u30b9\u306e\u30df\u30b9\u30d1\u30bf\u30fc\u30f3<\/h3>\n\n\n\n<table>\n<thead><tr><th>\u30df\u30b9\u306e\u7a2e\u985e<\/th><th>\u9593\u9055\u3063\u305f\u4f8b<\/th><th>\u6b63\u3057\u3044\u4f8b<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>\u30d0\u30c3\u30af\u30b9\u30e9\u30c3\u30b7\u30e5\u306e\u6b20\u843d<\/td><td>\"C:\\Users\\kohei\" & \"report.xlsx\"<\/td><td>\"C:\\\\Users\\\\kohei\\\\\" & \"report.xlsx\"<\/td><\/tr>\n<tr><td>\u5168\u89d2\u6587\u5b57\u306e\u6df7\u5165<\/td><td>\"C:\\Users\\kohei\\\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\\\"\uff08\u5168\u89d2\uff09<\/td><td>\u30d1\u30b9\u306b\u5168\u89d2\u3092\u907f\u3051\u308b\u304b\u3001\u65e5\u672c\u8a9e\u30d5\u30a9\u30eb\u30c0\u540d\u306b\u6ce8\u610f<\/td><\/tr>\n<tr><td>\u62e1\u5f35\u5b50\u306e\u7701\u7565\u30fb\u8aa4\u8a18<\/td><td>\"report\"\uff08.xlsx\u306a\u3057\uff09<\/td><td>\"report.xlsx\"\uff08\u62e1\u5f35\u5b50\u307e\u3067\u542b\u3080\uff09<\/td><\/tr>\n<tr><td>\u5909\u6570\u306e\u521d\u671f\u5316\u5fd8\u308c<\/td><td>Dim filePath As String\uff08\u5024\u3092\u8a2d\u5b9a\u305b\u305a\u4f7f\u7528\uff09<\/td><td>\u5fc5\u305afilePath = \"...\" \u3067\u5024\u3092\u4ee3\u5165\u3057\u3066\u304b\u3089\u4f7f\u3046<\/td><\/tr>\n<tr><td>\u672b\u5c3e\u30b9\u30da\u30fc\u30b9\u306e\u6df7\u5165<\/td><td>\"C:\\\\Data\\\\ \"\uff08\u672b\u5c3e\u30b9\u30da\u30fc\u30b9\uff09<\/td><td>\"C:\\\\Data\\\\\"\uff08\u30c8\u30ea\u30e0\u3059\u308b\uff09<\/td><\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u30d1\u30b9\u3092\u7d44\u307f\u7acb\u3066\u308b\u3068\u304d\u306e\u5b89\u5168\u306a\u65b9\u6cd5\nSub BuildSafePath()\n    &#x27; Environ\u95a2\u6570\u3067\u30e6\u30fc\u30b6\u30fc\u30d5\u30a9\u30eb\u30c0\u3092\u52d5\u7684\u306b\u53d6\u5f97\uff08\u74b0\u5883\u4f9d\u5b58\u3092\u907f\u3051\u308b\uff09\n    Dim userProfile As String\n    userProfile = Environ(&quot;USERPROFILE&quot;)  &#x27; C:\\Users\\kohei \u306a\u3069\u3092\u53d6\u5f97\n    Debug.Print &quot;USERPROFILE: &quot; &amp; userProfile\n\n    &#x27; \u30d1\u30b9\u306e\u7d50\u5408\uff08\u672b\u5c3e\u306e\\\u3092\u78ba\u8a8d\u3057\u3066\u4ed8\u3051\u308b\uff09\n    Dim folderPath As String\n    If Right(userProfile, 1) &lt;&gt; &quot;\\\\&quot; Then\n        folderPath = userProfile &amp; &quot;\\\\Desktop\\\\&quot;\n    Else\n        folderPath = userProfile &amp; &quot;Desktop\\\\&quot;\n    End If\n\n    Dim filePath As String\n    filePath = folderPath &amp; &quot;monthly_report.xlsx&quot;\n    Debug.Print &quot;Target: &quot; &amp; filePath\n\n    &#x27; \u5b58\u5728\u78ba\u8a8d\u3057\u3066\u304b\u3089\u958b\u304f\n    If Dir(filePath) &lt;&gt; &quot;&quot; Then\n        Workbooks.Open filePath\n    Else\n        MsgBox &quot;\u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093: &quot; &amp; vbCrLf &amp; filePath, vbCritical\n    End If\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<div class=\"balloon-wrap\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/ceo-sugasawa.jpg\" alt=\"\u4ee3\u8868\u83c5\u6fa4\">\n    <span class=\"balloon-name\">\u4ee3\u8868\u83c5\u6fa4<\/span>\n  <\/div>\n  <div class=\"balloon-body\">\u300c\u30de\u30af\u30ed\u3092\u81ea\u5206\u306ePC\u3067\u4f5c\u3063\u305f\u3089\u52d5\u304f\u3051\u3069\u3001\u4ed6\u306e\u4eba\u306ePC\u306b\u6e21\u3057\u305f\u3089\u52d5\u304b\u306a\u3044\u300d\u3068\u3044\u3046\u76f8\u8ac7\u306e\u591a\u304f\u306f\u3001\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u3092\u30cf\u30fc\u30c9\u30b3\u30fc\u30c9\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u539f\u56e0\u3067\u3059\u3002Environ(\"USERPROFILE\")\u3084ThisWorkbook.Path\u3092\u4f7f\u3063\u3066\u52d5\u7684\u306b\u30d1\u30b9\u3092\u4f5c\u308b\u7fd2\u6163\u3092\u3064\u3051\u308b\u3068\u3001\u74b0\u5883\u306b\u4f9d\u5b58\u3057\u306a\u3044\u30de\u30af\u30ed\u306b\u306a\u308a\u307e\u3059\u3002<\/div>\n<\/div>\n\n\n<div style=\"margin:48px 0 8px;display:flex;gap:12px;justify-content:center;flex-wrap:wrap;\"><a href=\"https:\/\/aikanri.genai-ai.co.jp\/seminar2-blog\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_content=cc-vba-error-1004&#038;blog_slug=cc-vba-error-1004\" target=\"_blank\" rel=\"noopener\" aria-label=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff08\u7121\u6599\u30fb1on1\u30fb60\u5206\uff09\u306e\u4e88\u7d04\u753b\u9762\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_seminar_claude_code_2026.jpg\" alt=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff5c\u7d4c\u55b6\u8005\u30fb\u4f1a\u793e\u5f79\u54e1\u5c02\u7528 1on1 60\u5206 \u7121\u6599\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_campaign=cc-vba-error-1004&#038;utm_content=h2-banner-kanri\" target=\"_blank\" rel=\"noopener\" aria-label=\"AI\u9b3c\u7ba1\u7406 \u516c\u5f0f\u30b5\u30a4\u30c8\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_blog_1to1.jpg\" alt=\"Claude Code\u3092\u7d4c\u55b6\u306b\u6d3b\u304b\u3057\u305f\u3044\u65b9\u3078 \u2014 AI\u9b3c\u7ba1\u7406\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><\/div>\n\n\n<div id=\"sec-03\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">03<\/span>\n  <span class=\"section-label\" style=\"display:block;\">CAUSE 2: SHEET NOT FOUND<\/span>\n  <span class=\"section-title\" style=\"display:block;\">\u539f\u56e02\uff1a\u5b58\u5728\u3057\u306a\u3044\u30b7\u30fc\u30c8\u30fb\u30bb\u30eb\u7bc4\u56f2\u3092\u6307\u5b9a\u3057\u305f<\/span>\n  <span class=\"section-desc\">\u30b7\u30fc\u30c8\u540d\u78ba\u8a8d\u30fb\u5b58\u5728\u30c1\u30a7\u30c3\u30af\u95a2\u6570\u30fbRange\u6307\u5b9a\u306e\u843d\u3068\u3057\u7a74<\/span>\n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u300cSheets(\"\u30b7\u30fc\u30c8\u540d\").Select\u300d\u3084\u300cSheets(\"\u30b7\u30fc\u30c8\u540d\").Cells(1,1).Value\u300d\u3092\u5b9f\u884c\u3057\u305f\u3068\u304d\u3001\u6307\u5b9a\u3057\u305f\u30b7\u30fc\u30c8\u540d\u306e\u30b7\u30fc\u30c8\u304c\u30ef\u30fc\u30af\u30d6\u30c3\u30af\u306b\u5b58\u5728\u3057\u306a\u3044\u3068\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u3053\u308c\u306f\u5148\u307b\u3069\u306e\u30d5\u30a1\u30a4\u30eb\u672a\u5b58\u5728\u3068\u4f3c\u3066\u3044\u307e\u3059\u304c\u3001\u300c\u30d5\u30a1\u30a4\u30eb\u306f\u5b58\u5728\u3059\u308b\u304c\u3001\u305d\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u306b\u305d\u306e\u30b7\u30fc\u30c8\u304c\u306a\u3044\u300d\u3068\u3044\u3046\u72b6\u6cc1\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3-1. \u30b7\u30fc\u30c8\u304c\u5b58\u5728\u3059\u308b\u304b\u78ba\u8a8d\u3059\u308b\u95a2\u6570<\/h3>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u30b7\u30fc\u30c8\u306e\u5b58\u5728\u78ba\u8a8d\u95a2\u6570\uff08\u518d\u5229\u7528\u53ef\u80fd\uff09\nFunction SheetExists(sheetName As String, Optional wb As Workbook) As Boolean\n    If wb Is Nothing Then Set wb = ThisWorkbook\n\n    Dim ws As Worksheet\n    On Error Resume Next\n    Set ws = wb.Sheets(sheetName)\n    On Error GoTo 0\n\n    SheetExists = Not (ws Is Nothing)\nEnd Function\n\n&#x27; \u4f7f\u3044\u65b9\nSub UseSheetExists()\n    Dim targetSheet As String\n    targetSheet = &quot;\u30c7\u30fc\u30bf\u96c6\u8a08&quot;\n\n    &#x27; \u30b7\u30fc\u30c8\u306e\u5b58\u5728\u78ba\u8a8d\n    If Not SheetExists(targetSheet) Then\n        MsgBox &quot;\u300c&quot; &amp; targetSheet &amp; &quot;\u300d\u30b7\u30fc\u30c8\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002&quot; &amp; vbCrLf &amp; _\n               &quot;\u30b7\u30fc\u30c8\u540d\u306e\u78ba\u8a8d\uff08\u30b9\u30da\u30fc\u30b9\u30fb\u5168\u89d2\u6587\u5b57\u306b\u6ce8\u610f\uff09\u3092\u304a\u9858\u3044\u3057\u307e\u3059\u3002&quot;, _\n               vbExclamation, &quot;\u30b7\u30fc\u30c8\u672a\u5b58\u5728&quot;\n        Exit Sub\n    End If\n\n    &#x27; \u5b89\u5168\u306b\u64cd\u4f5c\n    Dim ws As Worksheet\n    Set ws = ThisWorkbook.Sheets(targetSheet)\n    ws.Cells(1, 1).Value = &quot;\u51e6\u7406\u5b8c\u4e86&quot;\n    MsgBox &quot;\u51e6\u7406\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f&quot;\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">3-2. \u30b7\u30fc\u30c8\u540d\u306e\u3088\u304f\u3042\u308b\u30df\u30b9<\/h3>\n\n\n\n<table>\n<thead><tr><th>\u30df\u30b9\u306e\u7a2e\u985e<\/th><th>\u9593\u9055\u3063\u305f\u4f8b<\/th><th>\u6b63\u3057\u3044\u4f8b\u30fb\u5bfe\u51e6\u6cd5<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>\u5168\u89d2\u30b9\u30da\u30fc\u30b9\u306e\u6df7\u5165<\/td><td>Sheets(\"\u30c7\u30fc\u30bf\u3000\u96c6\u8a08\")\uff08\u5168\u89d2SP\uff09<\/td><td>\u30b7\u30fc\u30c8\u30bf\u30d6\u3092\u78ba\u8a8d\u3057\u3066\u6b63\u78ba\u306a\u540d\u524d\u3092\u30b3\u30d4\u30fc<\/td><\/tr>\n<tr><td>\u672b\u5c3e\u30b9\u30da\u30fc\u30b9\u306e\u6df7\u5165<\/td><td>Sheets(\"\u30c7\u30fc\u30bf\u96c6\u8a08 \")\uff08\u672b\u5c3eSP\uff09<\/td><td>Trim(sheetName)\u3067\u30c8\u30ea\u30e0\u3057\u3066\u304b\u3089\u4f7f\u3046<\/td><\/tr>\n<tr><td>\u5927\u6587\u5b57\u5c0f\u6587\u5b57\u306e\u9055\u3044<\/td><td>Sheets(\"DATA\")\uff08Excel\u306e\u30bf\u30d6\u306f\u300cdata\u300d\uff09<\/td><td>VBA\u306eSheets()\u306f\u5927\u6587\u5b57\u5c0f\u6587\u5b57\u3092\u533a\u5225\u3057\u306a\u3044\uff08\u305f\u3060\u3057\u5168\u89d2\u534a\u89d2\u306f\u533a\u5225\u3059\u308b\uff09<\/td><\/tr>\n<tr><td>\u30b7\u30fc\u30c8\u304c\u5225\u30d6\u30c3\u30af\u306b\u3042\u308b<\/td><td>Sheets(\"\u96c6\u8a08\")\uff08\u30ab\u30ec\u30f3\u30c8\u30d6\u30c3\u30af\u306b\u5b58\u5728\u3057\u306a\u3044\uff09<\/td><td>Workbooks(\"book1.xlsx\").Sheets(\"\u96c6\u8a08\")\u3068\u660e\u793a\u7684\u306b\u6307\u5b9a<\/td><\/tr>\n<tr><td>\u30b7\u30fc\u30c8\u3092\u524a\u9664\u30fb\u30ea\u30cd\u30fc\u30e0\u3057\u305f<\/td><td>\u53e4\u3044\u30b7\u30fc\u30c8\u540d\u3092\u30b3\u30fc\u30c9\u306b\u66f8\u3044\u305f\u307e\u307e<\/td><td>\u30b7\u30fc\u30c8\u540d\u3092\u5909\u6570\u7ba1\u7406\u3059\u308b\u304b\u30b3\u30fc\u30c9\u3092\u66f4\u65b0<\/td><\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<div style=\"background:#f0fdf4;border:1px solid #22c55e;border-radius:8px;padding:20px 24px;margin:24px 0;\">\n  <div style=\"display:flex;align-items:center;gap:8px;margin-bottom:12px;\">\n    <span style=\"font-size:18px;\">&#128161;<\/span>\n    <strong style=\"color:#16a34a;font-size:15px;\">\u30b7\u30fc\u30c8\u540d\u306f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3067\u306f\u306a\u304f\u540d\u524d\u3067\u6307\u5b9a\u3059\u308b<\/strong>\n  <\/div>\n  <p style=\"margin:0;font-size:15px;line-height:1.8;color:#333;\">Sheets(1)\u306e\u3088\u3046\u306a\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306f\u3001\u30b7\u30fc\u30c8\u306e\u9806\u756a\u304c\u5909\u308f\u308b\u3068\u610f\u56f3\u3057\u306a\u3044\u30b7\u30fc\u30c8\u3092\u53c2\u7167\u3057\u307e\u3059\u3002Sheets(\"\u30b7\u30fc\u30c8\u540d\")\u3067\u540d\u524d\u6307\u5b9a\u3059\u308b\u304b\u3001\u30b3\u30fc\u30c9\u30cd\u30fc\u30e0\uff08\u30b7\u30fc\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u540d\uff09\u3067\u76f4\u63a5Sheet1.Cells(1,1)\u306e\u3088\u3046\u306b\u53c2\u7167\u3059\u308b\u65b9\u304c\u5b89\u5168\u3067\u3059\u3002<\/p>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">3-3. Range\u6307\u5b9a\u306e\u30a8\u30e9\u30fc1004<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u300cRange(\"A0\")\u300d\u300cCells(0, 1)\u300d\u306a\u3069\u3001\u5b58\u5728\u3057\u306a\u3044\u30bb\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u6307\u5b9a\u3057\u3066\u3082\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u884c\u6570\u30fb\u5217\u6570\u306e\u8a08\u7b97\u7d50\u679c\u304c\u610f\u56f3\u305b\u305a0\u4ee5\u4e0b\u306b\u306a\u3063\u3066\u3044\u308b\u30b1\u30fc\u30b9\u3082\u591a\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; Range\u30fbCells\u6307\u5b9a\u3067\u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc1004\u306e\u30d1\u30bf\u30fc\u30f3\nSub RangeErrorExamples()\n    &#x27; \u30d1\u30bf\u30fc\u30f31: \u5b58\u5728\u3057\u306a\u3044\u30a2\u30c9\u30ec\u30b9\n    &#x27; Range(&quot;A0&quot;).Value = &quot;x&quot;       \u2190 \u30a8\u30e9\u30fc1004\uff08\u884c0\u306f\u5b58\u5728\u3057\u306a\u3044\uff09\n    &#x27; Range(&quot;A1048577&quot;).Value = &quot;x&quot; \u2190 \u30a8\u30e9\u30fc1004\uff08Excel\u306e\u6700\u5927\u884c\u6570\u8d85\u904e\uff09\n\n    &#x27; \u30d1\u30bf\u30fc\u30f32: \u5909\u6570\u304c0\u307e\u305f\u306f\u8ca0\u306e\u5024\u306b\u306a\u3063\u3066\u3044\u308b\n    Dim rowNum As Long\n    rowNum = 0  &#x27; \u2190 \u4f55\u304b\u306e\u8a08\u7b97\u30670\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u308b\n\n    &#x27; Cells(rowNum, 1).Value = &quot;x&quot;  \u2190 \u30a8\u30e9\u30fc1004\uff08rowNum\u304c0\uff09\n\n    &#x27; \u5bfe\u51e6: \u4e8b\u524d\u306b\u6709\u52b9\u306a\u7bc4\u56f2\u304b\u30c1\u30a7\u30c3\u30af\n    If rowNum &lt; 1 Or rowNum &gt; Rows.Count Then\n        MsgBox &quot;\u884c\u756a\u53f7\u304c\u4e0d\u6b63\u3067\u3059: &quot; &amp; rowNum, vbCritical\n        Exit Sub\n    End If\n\n    Cells(rowNum, 1).Value = &quot;x&quot;  &#x27; \u5b89\u5168\n\n    &#x27; \u30d1\u30bf\u30fc\u30f33: End(xlUp)\u3067\u7a7a\u30b7\u30fc\u30c8\u3092\u64cd\u4f5c\u3057\u305f\u3068\u304d\n    Dim lastRow As Long\n    lastRow = Cells(Rows.Count, 1).End(xlUp).Row\n    &#x27; \u2190 \u30c7\u30fc\u30bf\u304c\u306a\u3044\u5834\u5408lastRow\u306f1\uff08\u30d8\u30c3\u30c0\u30fc\u3082\u306a\u3044\u5834\u5408\uff09\n    Debug.Print &quot;lastRow: &quot; &amp; lastRow\n\n    &#x27; \u6700\u7d42\u884c\u304c1\u306e\u5834\u5408\uff08\u30c7\u30fc\u30bf\u306a\u3057\uff09\u306f\u51e6\u7406\u3057\u306a\u3044\n    If Cells(1, 1).Value = &quot;&quot; Then\n        MsgBox &quot;\u30c7\u30fc\u30bf\u304c\u3042\u308a\u307e\u305b\u3093&quot;, vbInformation\n        Exit Sub\n    End If\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<div class=\"balloon-wrap is-right\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/yamazaki-avatar.png\" alt=\"AI\u9b3c\u7ba1\u7406\u5c71\u5d0e\">\n    <span class=\"balloon-name\">AI\u9b3c\u7ba1\u7406\u5c71\u5d0e<\/span>\n  <\/div>\n  <div class=\"balloon-body\">End(xlUp)\u3067lastRow\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u306f\u5e83\u304f\u4f7f\u308f\u308c\u307e\u3059\u304c\u3001\u30b7\u30fc\u30c8\u304c\u7a7a\u306e\u3068\u304d\u306f1\u884c\u76ee\u3092\u8fd4\u3057\u307e\u3059\u3002\u300clastRow = 1\u3067Cells(1,1)\u304c\u7a7a\u300d\u306a\u3089\u30c7\u30fc\u30bf\u306a\u3057\u3001\u3068\u3044\u3046\u5224\u5b9a\u3092\u5165\u308c\u308b\u3053\u3068\u3067\u30a8\u30e9\u30fc\u3092\u9632\u3052\u307e\u3059\u3002Debug.Print \"lastRow: \" & lastRow\u3067lastRow\u306e\u5b9f\u969b\u306e\u5024\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u3082\u91cd\u8981\u3067\u3059\u3002<\/div>\n<\/div>\n\n\n<div style=\"margin:48px 0 8px;display:flex;gap:12px;justify-content:center;flex-wrap:wrap;\"><a href=\"https:\/\/aikanri.genai-ai.co.jp\/seminar2-blog\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_content=cc-vba-error-1004&#038;blog_slug=cc-vba-error-1004\" target=\"_blank\" rel=\"noopener\" aria-label=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff08\u7121\u6599\u30fb1on1\u30fb60\u5206\uff09\u306e\u4e88\u7d04\u753b\u9762\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_seminar_claude_code_2026.jpg\" alt=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff5c\u7d4c\u55b6\u8005\u30fb\u4f1a\u793e\u5f79\u54e1\u5c02\u7528 1on1 60\u5206 \u7121\u6599\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_campaign=cc-vba-error-1004&#038;utm_content=h2-banner-kanri\" target=\"_blank\" rel=\"noopener\" aria-label=\"AI\u9b3c\u7ba1\u7406 \u516c\u5f0f\u30b5\u30a4\u30c8\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_blog_1to1.jpg\" alt=\"Claude Code\u3092\u7d4c\u55b6\u306b\u6d3b\u304b\u3057\u305f\u3044\u65b9\u3078 \u2014 AI\u9b3c\u7ba1\u7406\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><\/div>\n\n\n<div id=\"sec-04\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">04<\/span>\n  <span class=\"section-label\" style=\"display:block;\">CAUSE 3: SELECT ON INACTIVE SHEET<\/span>\n  <span class=\"section-title\" style=\"display:block;\">\u539f\u56e03\uff1a\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306e\u30bb\u30eb\u3092Select\u3057\u3088\u3046\u3068\u3057\u305f<\/span>\n  <span class=\"section-desc\">Select\u3068Activate\u306e\u5236\u7d04\u30fbSelect\u3092\u4f7f\u308f\u306a\u3044\u300c\u5024\u6e21\u3057\u300d\u3078\u306e\u66f8\u304d\u63db\u3048<\/span>\n<\/h2>\n\n\n\n<div style=\"background:#f8f9fa;border-left:4px solid #6b7280;border-radius:0 8px 8px 0;padding:16px 20px;margin:20px 0;\">\n  <p style=\"margin:0 0 4px;font-size:13px;font-weight:700;color:#6b7280;letter-spacing:1px;\">&#128218; \u7528\u8a9e\u89e3\u8aac<\/p>\n  <p style=\"margin:0;font-size:15px;line-height:1.7;\"><strong>Select\u30e1\u30bd\u30c3\u30c9\u3068\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306e\u95a2\u4fc2<\/strong>\uff1aVBA\u306eSelect\u30e1\u30bd\u30c3\u30c9\u306fExcel\u306e\u300c\u73fe\u5728\u753b\u9762\u306b\u8868\u793a\u3055\u308c\u3066\u3044\u308b\uff08\u30a2\u30af\u30c6\u30a3\u30d6\u306a\uff09\u30b7\u30fc\u30c8\u300d\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u3057\u304b\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u3002\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306e\u30bb\u30eb\uff08ws.Cells(1,1)\u306a\u3069\uff09\u306b\u5bfe\u3057\u3066Select\u3092\u547c\u3076\u3068\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u89e3\u6c7a\u7b56\u306f\u300c\u305d\u306e\u30b7\u30fc\u30c8\u3092Activate\u3057\u3066\u304b\u3089Select\u3059\u308b\u300d\u304b\u300cSelect\u3092\u4f7f\u308f\u305a\u306b\u76f4\u63a5\u5024\u3092\u4ee3\u5165\u30fb\u53c2\u7167\u3059\u308b\u300d\u3067\u3059\u3002<\/p>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u30a8\u30e9\u30fc1004\u306e\u767a\u751f\u539f\u56e0\u3068\u3057\u3066\u7279\u306bVBA\u521d\u5fc3\u8005\u304c\u6df7\u4e71\u3057\u3084\u3059\u3044\u306e\u304c\u300c\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306eSelect\u554f\u984c\u300d\u3067\u3059\u3002Excel\u306e\u30de\u30af\u30ed\u8a18\u9332\u6a5f\u80fd\u3092\u4f7f\u3046\u3068\u300cSheets(\"Sheet1\").Select \u2192 Cells(1,1).Select \u2192 ActiveCell.Value = x\u300d\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u304c\u3001\u3053\u308c\u3092\u305d\u306e\u307e\u307e\u4f7f\u3046\u3068\u300cSheet1\u304c\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u306e\u3068\u304d\u300d\u306b\u30a8\u30e9\u30fc1004\u304c\u51fa\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4-1. Select\u3068Activate\u304c\u5931\u6557\u3059\u308b\u30b1\u30fc\u30b9<\/h3>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u30a8\u30e9\u30fc\u304c\u51fa\u308b\u30d1\u30bf\u30fc\u30f3\uff08\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u3078\u306eSelect\uff09\nSub BadSelectPattern()\n    &#x27; Sheet1\u304c\u753b\u9762\u306b\u8868\u793a\u3055\u308c\u3066\u3044\u306a\u3044\u72b6\u614b\u3067\u5b9f\u884c\u3059\u308b\u3068\u30a8\u30e9\u30fc1004\n    Sheets(&quot;Sheet1&quot;).Select           &#x27; \u2190 \u3053\u308c\u306fOK\uff08\u30b7\u30fc\u30c8\u3092\u30a2\u30af\u30c6\u30a3\u30d6\u306b\u3059\u308b\uff09\n\n    &#x27; \u2193 \u3053\u308c\u304c\u554f\u984c\uff1aSheet1\u304c\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u306e\u3068\u304d\u306bCells.Select\u3092\u547c\u3076\n    Sheets(&quot;Sheet2&quot;).Cells(1, 1).Select  &#x27; \u2190 \u30a8\u30e9\u30fc1004\n    &#x27; \uff08Sheet1\u3092Select\u3057\u305f\u5f8c\u3001\u3055\u3089\u306bSheet2\u306eCells\u3092Select\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u308b\uff09\nEnd Sub\n\n&#x27; \u3082\u3063\u3068\u5178\u578b\u7684\u306a\u30a8\u30e9\u30fc\u30d1\u30bf\u30fc\u30f3\nSub TypicalBadPattern()\n    Dim ws1 As Worksheet\n    Dim ws2 As Worksheet\n    Set ws1 = ThisWorkbook.Sheets(&quot;Sheet1&quot;)\n    Set ws2 = ThisWorkbook.Sheets(&quot;Sheet2&quot;)\n\n    ws1.Activate  &#x27; Sheet1\u3092\u30a2\u30af\u30c6\u30a3\u30d6\u306b\n\n    &#x27; Sheet2\u306e\u30bb\u30eb\u3092Select\u3057\u3088\u3046\u3068\u3059\u308b \u2192 \u30a8\u30e9\u30fc1004\n    ws2.Cells(1, 1).Select  &#x27; \u2190 Sheet2\u306f\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u306e\u3067NG\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">4-2. \u89e3\u6c7a\u7b56\u2460\uff1aActivate\u3057\u3066\u304b\u3089Select\u3059\u308b<\/h3>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u89e3\u6c7a\u7b561: \u30b7\u30fc\u30c8\u3092Activate\u3057\u3066\u304b\u3089Select\u3059\u308b\nSub FixWithActivate()\n    Dim ws2 As Worksheet\n    Set ws2 = ThisWorkbook.Sheets(&quot;Sheet2&quot;)\n\n    ws2.Activate              &#x27; \u2190 \u5148\u306b\u30b7\u30fc\u30c8\u3092\u30a2\u30af\u30c6\u30a3\u30d6\u306b\u3059\u308b\n    ws2.Cells(1, 1).Select    &#x27; \u2190 Activate\u5f8c\u306a\u3089Select\u3067\u304d\u308b\n    ActiveCell.Value = &quot;\u30c6\u30b9\u30c8&quot;\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">4-3. \u89e3\u6c7a\u7b56\u2461\uff08\u63a8\u5968\uff09\uff1aSelect\u3092\u4f7f\u308f\u305a\u76f4\u63a5\u5024\u3092\u4ee3\u5165\u3059\u308b<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u3088\u308a\u826f\u3044\u89e3\u6c7a\u7b56\u306f\u300c\u305d\u3082\u305d\u3082Select\u3092\u4f7f\u308f\u306a\u3044\u300d\u3053\u3068\u3067\u3059\u3002Select\u3092\u4f7f\u3046\u30b3\u30fc\u30c9\u306f\u30de\u30af\u30ed\u8a18\u9332\u304c\u81ea\u52d5\u751f\u6210\u3059\u308b\u30b3\u30fc\u30c9\u306b\u591a\u3044\u3067\u3059\u304c\u3001\u5b9f\u969b\u306b\u306f\u300c\u76f4\u63a5\u5024\u3092\u4ee3\u5165\u30fb\u53c2\u7167\u300d\u3059\u308b\u307b\u3046\u304c\u30b7\u30f3\u30d7\u30eb\u3067\u9ad8\u901f\u3067\u3059\u3002\u30b7\u30fc\u30c8\u3092Activate\u3057\u306a\u304f\u3066\u3082\u3069\u306e\u30b7\u30fc\u30c8\u3078\u3067\u3082\u5024\u306e\u8aad\u307f\u66f8\u304d\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u89e3\u6c7a\u7b562\uff08\u63a8\u5968\uff09: Select\u3092\u4f7f\u308f\u305a\u76f4\u63a5\u64cd\u4f5c\u3059\u308b\nSub BestPracticeNoSelect()\n    Dim ws1 As Worksheet\n    Dim ws2 As Worksheet\n    Set ws1 = ThisWorkbook.Sheets(&quot;Sheet1&quot;)\n    Set ws2 = ThisWorkbook.Sheets(&quot;Sheet2&quot;)\n\n    &#x27; Select\u306a\u3057\u3067\u76f4\u63a5\u5024\u3092\u4ee3\u5165\u30fb\u53c2\u7167\u3067\u304d\u308b\uff08\u3069\u306e\u30b7\u30fc\u30c8\u3067\u3082OK\uff09\n    ws1.Cells(1, 1).Value = &quot;Sheet1\u306e\u5024&quot;        &#x27; \u2190 \u30a2\u30af\u30c6\u30a3\u30d6\u3067\u306a\u304f\u3066\u3082OK\n    ws2.Cells(1, 1).Value = ws1.Cells(1, 1).Value  &#x27; \u2190 \u4e21\u65b9\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u3067\u3082OK\n    ws2.Range(&quot;B2:D5&quot;).ClearContents             &#x27; \u2190 \u7bc4\u56f2\u30af\u30ea\u30a2\u3082\u76f4\u63a5\u53ef\u80fd\n\n    MsgBox &quot;\u51e6\u7406\u5b8c\u4e86&quot;\nEnd Sub\n\n&#x27; \u30de\u30af\u30ed\u8a18\u9332\u3067\u751f\u6210\u3055\u308c\u305f\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u63db\u3048\u308b\u4f8b\n&#x27; ===== \u66f8\u304d\u63db\u3048\u524d\uff08\u30de\u30af\u30ed\u8a18\u9332\u306e\u30b3\u30fc\u30c9\uff09=====\n&#x27; Sheets(&quot;Sheet2&quot;).Select\n&#x27; Range(&quot;A1&quot;).Select\n&#x27; ActiveCell.FormulaR1C1 = &quot;\u30c6\u30b9\u30c8&quot;\n&#x27; Range(&quot;B1&quot;).Select\n&#x27; ActiveCell.FormulaR1C1 = &quot;\u30c7\u30fc\u30bf&quot;\n\n&#x27; ===== \u66f8\u304d\u63db\u3048\u5f8c\uff08\u63a8\u5968\u30d1\u30bf\u30fc\u30f3\uff09=====\nSub RefactoredMacro()\n    Dim ws As Worksheet\n    Set ws = ThisWorkbook.Sheets(&quot;Sheet2&quot;)\n    ws.Range(&quot;A1&quot;).Value = &quot;\u30c6\u30b9\u30c8&quot;   &#x27; \u2190 Select\u306a\u3057\u3001\u76f4\u63a5\u4ee3\u5165\n    ws.Range(&quot;B1&quot;).Value = &quot;\u30c7\u30fc\u30bf&quot;   &#x27; \u2190 Select\u306a\u3057\u3001\u76f4\u63a5\u4ee3\u5165\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<div style=\"background:#fef2f2;border:2px solid #dc2626;border-radius:8px;padding:20px 24px;margin:24px 0;\">\n  <div style=\"display:flex;align-items:center;gap:8px;margin-bottom:12px;\">\n    <span style=\"font-size:20px;\">&#9888;&#65039;<\/span>\n    <strong style=\"color:#dc2626;font-size:16px;\">\u30de\u30af\u30ed\u8a18\u9332\u306e\u30b3\u30fc\u30c9\u3092\u305d\u306e\u307e\u307e\u4f7f\u308f\u306a\u3044<\/strong>\n  <\/div>\n  <p style=\"margin:0;font-size:15px;line-height:1.8;color:#333;\">Excel\u306e\u30de\u30af\u30ed\u8a18\u9332\u6a5f\u80fd\u304c\u751f\u6210\u3059\u308b\u30b3\u30fc\u30c9\u306f\u300c\u4eba\u9593\u304c\u624b\u3067\u64cd\u4f5c\u3057\u305f\u901a\u308a\u306e\u624b\u9806\u300d\u3092\u8a18\u9332\u3059\u308b\u305f\u3081\u3001\u5927\u91cf\u306eSelect\/Activate\u304c\u542b\u307e\u308c\u307e\u3059\u3002\u3053\u306e\u30b3\u30fc\u30c9\u3092\u5225\u306e\u30b7\u30fc\u30c8\u304b\u3089\u547c\u3076\u3068\u30a8\u30e9\u30fc1004\u304c\u51fa\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002\u30de\u30af\u30ed\u8a18\u9332\u306f\u30b3\u30fc\u30c9\u306e\u53c2\u8003\u306b\u3057\u3066\u3001Select\u3092Value\u4ee3\u5165\u306b\u66f8\u304d\u63db\u3048\u308b\u7fd2\u6163\u3092\u3064\u3051\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<\/div>\n\n\n\n<div class=\"g-flow-row\" style=\"margin:24px 0;\">\n  <div class=\"g-flow-item\"><strong>\u30de\u30af\u30ed\u8a18\u9332\u3067<br>Select\u591a\u7528\u30b3\u30fc\u30c9<\/strong><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u3067<br>Select\u3092\u547c\u3076<\/strong><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u30a8\u30e9\u30fc1004<br>\u767a\u751f<\/strong><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>Select\u3092\u524a\u9664\u3057\u3066<br>\u76f4\u63a5\u5024\u4ee3\u5165\u306b\u5909\u66f4<\/strong><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u3069\u306e\u30b7\u30fc\u30c8\u304b\u3089\u3067\u3082<br>\u6b63\u5e38\u52d5\u4f5c<\/strong><\/div>\n<\/div>\n\n\n\n<div class=\"balloon-wrap\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/ceo-sugasawa.jpg\" alt=\"\u4ee3\u8868\u83c5\u6fa4\">\n    <span class=\"balloon-name\">\u4ee3\u8868\u83c5\u6fa4<\/span>\n  <\/div>\n  <div class=\"balloon-body\">\u300cSelect\u3092\u4f7f\u308f\u306a\u3044\u30b3\u30fc\u30c9\u300d\u306fVBA\u306e\u57fa\u672c\u30b9\u30ad\u30eb\u3068\u3057\u3066\u975e\u5e38\u306b\u91cd\u8981\u3067\u3059\u3002Select\/Activate\u3092\u5fb9\u5e95\u7684\u306b\u306a\u304f\u3059\u3053\u3068\u3067\u3001\u30b3\u30fc\u30c9\u304c\u77ed\u304f\u306a\u308a\u3001\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306e\u30a8\u30e9\u30fc\u304c\u6839\u672c\u7684\u306b\u89e3\u6c7a\u3057\u307e\u3059\u3002\u51e6\u7406\u901f\u5ea6\u3082\u5927\u5e45\u306b\u5411\u4e0a\u3057\u307e\u3059\uff08ScreenUpdating\u3092False\u306b\u3057\u306a\u304f\u3066\u3082\u901f\u304f\u306a\u308a\u307e\u3059\uff09\u3002<\/div>\n<\/div>\n\n\n<div style=\"margin:48px 0 8px;display:flex;gap:12px;justify-content:center;flex-wrap:wrap;\"><a href=\"https:\/\/aikanri.genai-ai.co.jp\/seminar2-blog\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_content=cc-vba-error-1004&#038;blog_slug=cc-vba-error-1004\" target=\"_blank\" rel=\"noopener\" aria-label=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff08\u7121\u6599\u30fb1on1\u30fb60\u5206\uff09\u306e\u4e88\u7d04\u753b\u9762\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_seminar_claude_code_2026.jpg\" alt=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff5c\u7d4c\u55b6\u8005\u30fb\u4f1a\u793e\u5f79\u54e1\u5c02\u7528 1on1 60\u5206 \u7121\u6599\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_campaign=cc-vba-error-1004&#038;utm_content=h2-banner-kanri\" target=\"_blank\" rel=\"noopener\" aria-label=\"AI\u9b3c\u7ba1\u7406 \u516c\u5f0f\u30b5\u30a4\u30c8\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_blog_1to1.jpg\" alt=\"Claude Code\u3092\u7d4c\u55b6\u306b\u6d3b\u304b\u3057\u305f\u3044\u65b9\u3078 \u2014 AI\u9b3c\u7ba1\u7406\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><\/div>\n\n\n<div id=\"sec-05\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">05<\/span>\n  <span class=\"section-label\" style=\"display:block;\">CAUSE 4: COPY PASTE MISMATCH<\/span>\n  <span class=\"section-title\" style=\"display:block;\">\u539f\u56e04\uff1a\u30b3\u30d4\u30fc\u5143\u3068\u30b3\u30d4\u30fc\u5148\u306e\u7bc4\u56f2\u304c\u7570\u306a\u308b<\/span>\n  <span class=\"section-desc\">Copy\/Paste\u306e\u30a8\u30e9\u30fc1004\u30fbPasteSpecial\u306e\u6b63\u3057\u3044\u4f7f\u3044\u65b9<\/span>\n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u30bb\u30eb\u7bc4\u56f2\u306e\u30b3\u30d4\u30fc\u3068\u30da\u30fc\u30b9\u30c8\u3092\u884c\u3046\u3068\u304d\u3001\u300c\u30b3\u30d4\u30fc\u5143\u306e\u5f62\u72b6\u300d\u3068\u300c\u30da\u30fc\u30b9\u30c8\u5148\u306e\u5f62\u72b6\u300d\u304c\u5408\u308f\u306a\u3044\u5834\u5408\u306b\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u7279\u306b\u8907\u6570\u884c\u30fb\u8907\u6570\u5217\u3092\u30b3\u30d4\u30fc\u3057\u3066\u30011\u30bb\u30eb\u3084\u7570\u306a\u308b\u30b5\u30a4\u30ba\u306e\u7bc4\u56f2\u306b\u30da\u30fc\u30b9\u30c8\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u304d\u306b\u8d77\u304d\u307e\u3059\u3002\u307e\u305f\u3001\u30b3\u30d4\u30fc\u5f8c\u306b\u5225\u306e\u64cd\u4f5c\u3092\u3057\u3066\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u304c\u89e3\u653e\u3055\u308c\u305f\u5f8c\u306bPaste\u3092\u547c\u3093\u3067\u3082\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u30b3\u30d4\u30fc\u30fb\u30da\u30fc\u30b9\u30c8\u306e\u30a8\u30e9\u30fc1004\u30d1\u30bf\u30fc\u30f3\u3068\u89e3\u6c7a\u7b56\nSub CopyPastePatterns()\n    Dim ws As Worksheet\n    Set ws = ThisWorkbook.Sheets(&quot;Sheet1&quot;)\n\n    &#x27; === \u30d1\u30bf\u30fc\u30f31: \u30b3\u30d4\u30fc\u5f8c\u306b\u5225\u306e\u64cd\u4f5c\u3092\u3057\u3066\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u304c\u5931\u308f\u308c\u308b ===\n    ws.Range(&quot;A1:A10&quot;).Copy\n    &#x27; \u2193 \u3053\u3053\u3067\u5225\u306e\u30bb\u30eb\u3092\u64cd\u4f5c\u3059\u308b\u3068\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u304c\u89e3\u653e\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308b\n    ws.Cells(1, 3).Value = &quot;\u306a\u306b\u304b&quot;  &#x27; \u2190 \u3053\u306e\u64cd\u4f5c\u3067\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u304c\u89e3\u653e\n    &#x27; ws.Range(&quot;C1:C10&quot;).PasteSpecial  \u2190 \u30a8\u30e9\u30fc1004\uff08\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u304c\u7a7a\uff09\n\n    &#x27; === \u89e3\u6c7a\u7b56: Copy\u3068Paste\u306f\u9023\u7d9a\u3057\u3066\u5b9f\u884c\u3059\u308b ===\n    ws.Range(&quot;A1:A10&quot;).Copy ws.Range(&quot;C1&quot;)  &#x27; \u2190 1\u884c\u3067\u30b3\u30d4\u30fc\u5148\u3092\u6307\u5b9a\uff08\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u4e0d\u8981\uff09\n    MsgBox &quot;\u30d1\u30bf\u30fc\u30f31 \u89e3\u6c7a\u6e08\u307f&quot;\n\n    &#x27; === \u30d1\u30bf\u30fc\u30f32: \u30b3\u30d4\u30fc\u5143\u304c\u8907\u6570\u5217\u3067\u30da\u30fc\u30b9\u30c8\u5148\u304c1\u5217\u3060\u3051 ===\n    ws.Range(&quot;A1:C10&quot;).Copy  &#x27; 3\u5217\u00d710\u884c\u3092\u30b3\u30d4\u30fc\n    &#x27; ws.Range(&quot;E1:E10&quot;).PasteSpecial  \u2190 \u30a8\u30e9\u30fc\uff08E1:E10\u306f1\u5217\u306a\u306e\u3067\u5f62\u304c\u5408\u308f\u306a\u3044\uff09\n\n    &#x27; \u89e3\u6c7a\u7b56: \u30da\u30fc\u30b9\u30c8\u5148\u306f\u5de6\u4e0a\u30bb\u30eb\u306e\u307f\u6307\u5b9a\uff08Excel\u304c\u81ea\u52d5\u3067\u5e83\u3052\u308b\uff09\n    ws.Range(&quot;A1:C10&quot;).Copy ws.Range(&quot;E1&quot;)  &#x27; \u2190 E1\u3092\u8d77\u70b9\u306b\u81ea\u52d5\u5c55\u958b\uff08E1:G10\uff09\n    MsgBox &quot;\u30d1\u30bf\u30fc\u30f32 \u89e3\u6c7a\u6e08\u307f&quot;\n\n    Application.CutCopyMode = False  &#x27; \u30b3\u30d4\u30fc\u30e2\u30fc\u30c9\uff08\u70b9\u7dda\u67a0\uff09\u3092\u89e3\u9664\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">5-1. PasteSpecial\u306e\u30a8\u30e9\u30fc1004<\/h3>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; PasteSpecial\u306e\u30a8\u30e9\u30fc1004\u5bfe\u7b56\nSub SafePasteSpecial()\n    Dim srcWs As Worksheet\n    Dim dstWs As Worksheet\n    Set srcWs = ThisWorkbook.Sheets(&quot;\u30c7\u30fc\u30bf&quot;)\n    Set dstWs = ThisWorkbook.Sheets(&quot;\u96c6\u8a08&quot;)\n\n    &#x27; === \u5024\u306e\u307f\u8cbc\u308a\u4ed8\u3051\uff08\u66f8\u5f0f\u3092\u9664\u3044\u305f\u30b3\u30d4\u30fc\uff09===\n    srcWs.Range(&quot;A1:D100&quot;).Copy\n\n    &#x27; PasteSpecial\u524d\u306b\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u304c\u6709\u52b9\u304b\u3092\u78ba\u8a8d\uff08\u78ba\u5b9f\u306a\u65b9\u6cd5\uff09\n    On Error GoTo PasteError\n    dstWs.Range(&quot;A1&quot;).PasteSpecial Paste:=xlPasteValues\n    On Error GoTo 0\n\n    Application.CutCopyMode = False\n    Exit Sub\n\nPasteError:\n    Application.CutCopyMode = False\n    MsgBox &quot;\u8cbc\u308a\u4ed8\u3051\u306b\u5931\u6557\u3057\u307e\u3057\u305f\uff08\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u304c\u7a7a\u306e\u53ef\u80fd\u6027\uff09\u3002&quot; &amp; vbCrLf &amp; _\n           &quot;\u30a8\u30e9\u30fc: &quot; &amp; Err.Description, vbCritical\nEnd Sub\n\n&#x27; === \u30b3\u30d4\u30fc\u305b\u305a\u306b\u76f4\u63a5\u5024\u3092\u8ee2\u9001\u3059\u308b\u65b9\u6cd5\uff08\u63a8\u5968\uff09===\nSub DirectValueTransfer()\n    Dim srcWs As Worksheet\n    Dim dstWs As Worksheet\n    Set srcWs = ThisWorkbook.Sheets(&quot;\u30c7\u30fc\u30bf&quot;)\n    Set dstWs = ThisWorkbook.Sheets(&quot;\u96c6\u8a08&quot;)\n\n    &#x27; PasteSpecial\u3092\u4f7f\u308f\u305a\u76f4\u63a5\u5024\u3092\u4ee3\u5165\uff08\u6700\u3082\u5b89\u5168\u30fb\u9ad8\u901f\uff09\n    dstWs.Range(&quot;A1:D100&quot;).Value = srcWs.Range(&quot;A1:D100&quot;).Value\n    &#x27; \u2190 \u30b3\u30d4\u30fc\u4e0d\u8981\u3001\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u4e0d\u8981\u3001\u30a8\u30e9\u30fc1004\u306e\u30ea\u30b9\u30af\u306a\u3057\n\n    MsgBox &quot;\u8ee2\u9001\u5b8c\u4e86&quot;\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<div style=\"background:#f0fdf4;border:1px solid #22c55e;border-radius:8px;padding:20px 24px;margin:24px 0;\">\n  <div style=\"display:flex;align-items:center;gap:8px;margin-bottom:12px;\">\n    <span style=\"font-size:18px;\">&#128161;<\/span>\n    <strong style=\"color:#16a34a;font-size:15px;\">\u30b3\u30d4\u30fc&\u30da\u30fc\u30b9\u30c8\u3088\u308a\u76f4\u63a5\u5024\u4ee3\u5165\u304c\u5b89\u5168<\/strong>\n  <\/div>\n  <p style=\"margin:0;font-size:15px;line-height:1.8;color:#333;\">VBA\u3067\u30c7\u30fc\u30bf\u3092\u5225\u30b7\u30fc\u30c8\u30fb\u5225\u30d6\u30c3\u30af\u306b\u8ee2\u9001\u3059\u308b\u3068\u304d\u3001Copy\u3068PasteSpecial\u3088\u308a\u3082\u300cRange.Value = Range.Value\u300d\u306e\u76f4\u63a5\u4ee3\u5165\u306e\u307b\u3046\u304c\u5b89\u5168\u3067\u9ad8\u901f\u3067\u3059\u3002\u5024\u306e\u307f\u306e\u8ee2\u9001\u306a\u3089\u30b3\u30d4\u30fc\u3092\u7d4c\u7531\u3059\u308b\u5fc5\u8981\u306f\u307e\u3063\u305f\u304f\u3042\u308a\u307e\u305b\u3093\u3002\u66f8\u5f0f\u3082\u30b3\u30d4\u30fc\u3057\u305f\u3044\u5834\u5408\u306e\u307fCopy\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<\/div>\n\n\n\n<div style=\"background:#f8f9fa;border-left:4px solid #6b7280;border-radius:0 8px 8px 0;padding:16px 20px;margin:20px 0;\">\n  <p style=\"margin:0 0 4px;font-size:13px;font-weight:700;color:#6b7280;letter-spacing:1px;\">&#128218; \u7528\u8a9e\u89e3\u8aac<\/p>\n  <p style=\"margin:0;font-size:15px;line-height:1.7;\"><strong>DisplayAlerts\u30d7\u30ed\u30d1\u30c6\u30a3<\/strong>\uff1aApplication.DisplayAlerts\u3092False\u306b\u8a2d\u5b9a\u3059\u308b\u3068\u3001Excel\u304c\u901a\u5e38\u8868\u793a\u3059\u308b\u78ba\u8a8d\u30c0\u30a4\u30a2\u30ed\u30b0\uff08\u300c\u30b7\u30fc\u30c8\u3092\u524a\u9664\u3057\u307e\u3059\u304b\uff1f\u300d\u300c\u30d5\u30a1\u30a4\u30eb\u3092\u4e0a\u66f8\u304d\u3057\u307e\u3059\u304b\uff1f\u300d\u306a\u3069\uff09\u3092\u81ea\u52d5\u7684\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u56de\u7b54\u3067\u51e6\u7406\u3057\u307e\u3059\u3002\u30b3\u30d4\u30fc\u64cd\u4f5c\u5f8c\u306bDisplayAlerts = False\u3092\u8a2d\u5b9a\u3059\u308b\u3068\u30b3\u30d4\u30fc\u30e2\u30fc\u30c9\u3082\u89e3\u9664\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u5fc5\u305a\u51e6\u7406\u306e\u6700\u5f8c\u306bApplication.DisplayAlerts = True\u3067\u5143\u306b\u623b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<\/div>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; DisplayAlerts\u3092\u4f7f\u3046\u5834\u9762\u3068\u6ce8\u610f\u70b9\nSub DisplayAlertsExample()\n    &#x27; \u30b7\u30fc\u30c8\u306e\u524a\u9664\uff08\u78ba\u8a8d\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u51fa\u3055\u306a\u3044\uff09\n    Application.DisplayAlerts = False\n    On Error Resume Next  &#x27; \u3059\u3067\u306b\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306e\u30a8\u30e9\u30fc\u3092\u7121\u8996\n    ThisWorkbook.Sheets(&quot;\u4e00\u6642\u30b7\u30fc\u30c8&quot;).Delete\n    On Error GoTo 0\n    Application.DisplayAlerts = True  &#x27; \u2190 \u5fc5\u305a\u5143\u306b\u623b\u3059\uff01\n\n    &#x27; \u30d5\u30a1\u30a4\u30eb\u306e\u4e0a\u66f8\u304d\u4fdd\u5b58\uff08\u78ba\u8a8d\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u51fa\u3055\u306a\u3044\uff09\n    Application.DisplayAlerts = False\n    ActiveWorkbook.SaveAs &quot;C:\\Data\\output.xlsx&quot;, xlOpenXMLWorkbook\n    Application.DisplayAlerts = True  &#x27; \u2190 \u5fc5\u305a\u5143\u306b\u623b\u3059\uff01\n\n    MsgBox &quot;\u5b8c\u4e86&quot;\nEnd Sub<\/pre>\n<\/div>\n\n\n<div style=\"margin:48px 0 8px;display:flex;gap:12px;justify-content:center;flex-wrap:wrap;\"><a href=\"https:\/\/aikanri.genai-ai.co.jp\/seminar2-blog\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_content=cc-vba-error-1004&#038;blog_slug=cc-vba-error-1004\" target=\"_blank\" rel=\"noopener\" aria-label=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff08\u7121\u6599\u30fb1on1\u30fb60\u5206\uff09\u306e\u4e88\u7d04\u753b\u9762\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_seminar_claude_code_2026.jpg\" alt=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff5c\u7d4c\u55b6\u8005\u30fb\u4f1a\u793e\u5f79\u54e1\u5c02\u7528 1on1 60\u5206 \u7121\u6599\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_campaign=cc-vba-error-1004&#038;utm_content=h2-banner-kanri\" target=\"_blank\" rel=\"noopener\" aria-label=\"AI\u9b3c\u7ba1\u7406 \u516c\u5f0f\u30b5\u30a4\u30c8\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_blog_1to1.jpg\" alt=\"Claude Code\u3092\u7d4c\u55b6\u306b\u6d3b\u304b\u3057\u305f\u3044\u65b9\u3078 \u2014 AI\u9b3c\u7ba1\u7406\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><\/div>\n\n\n<div id=\"sec-06\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">06<\/span>\n  <span class=\"section-label\" style=\"display:block;\">CAUSE 5: PROTECTED SHEET<\/span>\n  <span class=\"section-title\" style=\"display:block;\">\u539f\u56e05\uff1a\u4fdd\u8b77\u3055\u308c\u305f\u30b7\u30fc\u30c8\u306b\u66f8\u304d\u8fbc\u3082\u3046\u3068\u3057\u305f<\/span>\n  <span class=\"section-desc\">\u30b7\u30fc\u30c8\u4fdd\u8b77\u306e\u691c\u77e5\u30fbUnprotect\u30fb\u30d1\u30b9\u30ef\u30fc\u30c9\u4ed8\u304d\u4fdd\u8b77\u306e\u89e3\u9664<\/span>\n<\/h2>\n\n\n\n<div style=\"background:#f8f9fa;border-left:4px solid #6b7280;border-radius:0 8px 8px 0;padding:16px 20px;margin:20px 0;\">\n  <p style=\"margin:0 0 4px;font-size:13px;font-weight:700;color:#6b7280;letter-spacing:1px;\">&#128218; \u7528\u8a9e\u89e3\u8aac<\/p>\n  <p style=\"margin:0;font-size:15px;line-height:1.7;\"><strong>\u4fdd\u8b77\u30b7\u30fc\u30c8\uff08Protect\u3068Unprotect\uff09<\/strong>\uff1aExcel\u30b7\u30fc\u30c8\u306e\u300c\u30b7\u30fc\u30c8\u306e\u4fdd\u8b77\u300d\u6a5f\u80fd\uff08\u30db\u30fc\u30e0\u30bf\u30d6\u3084\u30ec\u30d3\u30e5\u30fc\u30bf\u30d6\u304b\u3089\u8a2d\u5b9a\uff09\u304c\u30aa\u30f3\u306e\u72b6\u614b\u3002\u4fdd\u8b77\u3055\u308c\u305f\u30b7\u30fc\u30c8\u306bVBA\u3067Cells.Value = x\u306a\u3069\u306e\u66f8\u304d\u8fbc\u307f\u64cd\u4f5c\u3092\u884c\u3046\u3068\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3057\u307e\u3059\u3002VBA\u304b\u3089ws.Unprotect\uff08\u30d1\u30b9\u30ef\u30fc\u30c9\uff09\u3067\u4fdd\u8b77\u3092\u89e3\u9664\u3057\u3066\u64cd\u4f5c\u3057\u3001\u7d42\u4e86\u5f8c\u306bws.Protect\uff08\u30d1\u30b9\u30ef\u30fc\u30c9\uff09\u3067\u518d\u4fdd\u8b77\u3059\u308b\u306e\u304c\u57fa\u672c\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002<\/p>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u30b7\u30fc\u30c8\u306e\u4fdd\u8b77\u304c\u6709\u52b9\u306a\u72b6\u614b\u3067\u3001\u305d\u306e\u30b7\u30fc\u30c8\u306e\u30bb\u30eb\u306b\u5024\u3092\u66f8\u304d\u8fbc\u3082\u3046\u3068\u3059\u308b\u3068\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u300c\u30e6\u30fc\u30b6\u30fc\u306e\u8aa4\u64cd\u4f5c\u9632\u6b62\u306e\u305f\u3081\u306b\u4fdd\u8b77\u3092\u304b\u3051\u305f\u30b7\u30fc\u30c8\u3092VBA\u3067\u66f4\u65b0\u3057\u305f\u3044\u300d\u3068\u3044\u3046\u5834\u9762\u3067\u3088\u304f\u906d\u9047\u3059\u308b\u30b1\u30fc\u30b9\u3067\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u4fdd\u8b77\u30b7\u30fc\u30c8\u3078\u306e\u66f8\u304d\u8fbc\u307f\u30a8\u30e9\u30fc\u3068\u89e3\u6c7a\u7b56\nSub ProtectedSheetError()\n    Dim ws As Worksheet\n    Set ws = ThisWorkbook.Sheets(&quot;\u8a2d\u5b9a\u30b7\u30fc\u30c8&quot;)\n\n    &#x27; ===== \u4fdd\u8b77\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3059\u308b =====\n    If ws.ProtectContents Then\n        Debug.Print &quot;\u30b7\u30fc\u30c8\u306f\u4fdd\u8b77\u3055\u308c\u3066\u3044\u307e\u3059&quot;\n    Else\n        Debug.Print &quot;\u30b7\u30fc\u30c8\u306f\u4fdd\u8b77\u3055\u308c\u3066\u3044\u307e\u305b\u3093&quot;\n    End If\n\n    &#x27; ===== \u89e3\u6c7a\u7b56: Unprotect\u3057\u3066\u66f8\u304d\u8fbc\u307f\u2192\u518dProtect =====\n    Const SHEET_PASSWORD As String = &quot;password123&quot;  &#x27; \u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u306a\u3044\u5834\u5408\u306f\u7a7a\u6587\u5b57\n\n    &#x27; \u4fdd\u8b77\u3092\u89e3\u9664\n    ws.Unprotect Password:=SHEET_PASSWORD\n\n    &#x27; \u66f8\u304d\u8fbc\u307f\u64cd\u4f5c\n    ws.Cells(1, 1).Value = &quot;\u66f4\u65b0\u6e08\u307f&quot;\n    ws.Cells(2, 1).Value = Now()\n\n    &#x27; \u4fdd\u8b77\u3092\u518d\u8a2d\u5b9a\uff08\u51e6\u7406\u5f8c\u306f\u5fc5\u305a\u623b\u3059\uff09\n    ws.Protect Password:=SHEET_PASSWORD, _\n               DrawingObjects:=True, _\n               Contents:=True, _\n               Scenarios:=True\n\n    MsgBox &quot;\u4fdd\u8b77\u30b7\u30fc\u30c8\u3078\u306e\u66f8\u304d\u8fbc\u307f\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f&quot;\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">6-1. \u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3082\u4fdd\u8b77\u3092\u78ba\u5b9f\u306b\u518d\u8a2d\u5b9a\u3059\u308b<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fdd\u8b77\u3092\u89e3\u9664\u3057\u3066\u51e6\u7406\u3059\u308b\u5834\u5408\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u3082\u5fc5\u305a\u4fdd\u8b77\u3092\u518d\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30a8\u30e9\u30fc\u3067\u4e2d\u65ad\u3059\u308b\u3068\u4fdd\u8b77\u304c\u89e3\u9664\u3055\u308c\u305f\u307e\u307e\u306b\u306a\u308a\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u8aa4\u3063\u3066\u7de8\u96c6\u3067\u304d\u3066\u3057\u307e\u3044\u307e\u3059\u3002On Error GoTo\u306eErrorHandler\u3067\u3082\u4fdd\u8b77\u306e\u518d\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u3082\u4fdd\u8b77\u3092\u78ba\u5b9f\u306b\u518d\u8a2d\u5b9a\u3059\u308b\u30d1\u30bf\u30fc\u30f3\nSub SafeProtectedSheetEdit()\n    Dim ws As Worksheet\n    Set ws = ThisWorkbook.Sheets(&quot;\u8a2d\u5b9a\u30b7\u30fc\u30c8&quot;)\n    Const PW As String = &quot;mypassword&quot;\n\n    Dim wasProtected As Boolean\n    wasProtected = ws.ProtectContents  &#x27; \u4fdd\u8b77\u72b6\u614b\u3092\u8a18\u9332\n\n    On Error GoTo ErrorHandler\n\n    &#x27; \u4fdd\u8b77\u3092\u89e3\u9664\uff08\u4fdd\u8b77\u3055\u308c\u3066\u3044\u305f\u5834\u5408\u306e\u307f\uff09\n    If wasProtected Then ws.Unprotect Password:=PW\n\n    &#x27; \u30c7\u30fc\u30bf\u66f8\u304d\u8fbc\u307f\uff08\u3053\u3053\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u53ef\u80fd\u6027\uff09\n    ws.Cells(1, 1).Value = &quot;\u66f4\u65b0\u5024&quot;\n    ws.Cells(2, 1).Value = Now()\n\n    &#x27; \u6b63\u5e38\u5b8c\u4e86\u5f8c\u306b\u518d\u4fdd\u8b77\n    If wasProtected Then ws.Protect Password:=PW, Contents:=True\n    MsgBox &quot;\u66f4\u65b0\u5b8c\u4e86&quot;\n    Exit Sub\n\nErrorHandler:\n    &#x27; \u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3082\u4fdd\u8b77\u3092\u5fc5\u305a\u518d\u8a2d\u5b9a\n    If wasProtected Then\n        On Error Resume Next  &#x27; \u518d\u4fdd\u8b77\u306b\u5931\u6557\u3057\u3066\u3082\u6b62\u3081\u306a\u3044\n        ws.Protect Password:=PW, Contents:=True\n        On Error GoTo 0\n    End If\n    MsgBox &quot;\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f: &quot; &amp; Err.Description, vbCritical\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<div style=\"background:#fef2f2;border:2px solid #dc2626;border-radius:8px;padding:20px 24px;margin:24px 0;\">\n  <div style=\"display:flex;align-items:center;gap:8px;margin-bottom:12px;\">\n    <span style=\"font-size:20px;\">&#9888;&#65039;<\/span>\n    <strong style=\"color:#dc2626;font-size:16px;\">\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u30b3\u30fc\u30c9\u306b\u76f4\u66f8\u304d\u3057\u306a\u3044<\/strong>\n  <\/div>\n  <p style=\"margin:0;font-size:15px;line-height:1.8;color:#333;\">\u30b7\u30fc\u30c8\u4fdd\u8b77\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092VBA\u30b3\u30fc\u30c9\u306b\u76f4\u63a5\u66f8\u304f\u3068\u3001VBA\u30a8\u30c7\u30a3\u30bf\u3092\u958b\u3051\u308b\u4eba\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u898b\u3089\u308c\u307e\u3059\u3002\u91cd\u8981\u306a\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u5834\u5408\u306f\u300cVBA\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u3082\u30d1\u30b9\u30ef\u30fc\u30c9\uff08\u30ed\u30c3\u30af\uff09\u3092\u304b\u3051\u308b\u300d\u304b\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5225\u30bb\u30eb\u30fb\u5225\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3057\u3066VBA\u304b\u3089\u8aad\u307f\u8fbc\u3080\u8a2d\u8a08\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<\/div>\n\n\n<div style=\"margin:48px 0 8px;display:flex;gap:12px;justify-content:center;flex-wrap:wrap;\"><a href=\"https:\/\/aikanri.genai-ai.co.jp\/seminar2-blog\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_content=cc-vba-error-1004&#038;blog_slug=cc-vba-error-1004\" target=\"_blank\" rel=\"noopener\" aria-label=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff08\u7121\u6599\u30fb1on1\u30fb60\u5206\uff09\u306e\u4e88\u7d04\u753b\u9762\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_seminar_claude_code_2026.jpg\" alt=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff5c\u7d4c\u55b6\u8005\u30fb\u4f1a\u793e\u5f79\u54e1\u5c02\u7528 1on1 60\u5206 \u7121\u6599\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_campaign=cc-vba-error-1004&#038;utm_content=h2-banner-kanri\" target=\"_blank\" rel=\"noopener\" aria-label=\"AI\u9b3c\u7ba1\u7406 \u516c\u5f0f\u30b5\u30a4\u30c8\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_blog_1to1.jpg\" alt=\"Claude Code\u3092\u7d4c\u55b6\u306b\u6d3b\u304b\u3057\u305f\u3044\u65b9\u3078 \u2014 AI\u9b3c\u7ba1\u7406\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><\/div>\n\n\n<div id=\"sec-07\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">07<\/span>\n  <span class=\"section-label\" style=\"display:block;\">CAUSE 6: NAMED RANGE ERROR<\/span>\n  <span class=\"section-title\" style=\"display:block;\">\u539f\u56e06\uff1a\u540d\u524d\u4ed8\u304d\u7bc4\u56f2\u30fb\u30c6\u30fc\u30d6\u30eb\u306e\u6307\u5b9a\u30df\u30b9<\/span>\n  <span class=\"section-desc\">Names\u30fbListObjects\u30fb\u5b9a\u7fa9\u6e08\u307f\u540d\u524d\u306e\u5b58\u5728\u78ba\u8a8d\u3068\u5b89\u5168\u306a\u53c2\u7167\u65b9\u6cd5<\/span>\n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Excel\u306e\u300c\u540d\u524d\u4ed8\u304d\u7bc4\u56f2\u300d\uff08\u6570\u5f0f\u30d0\u30fc\u5de6\u306e\u540d\u524d\u30dc\u30c3\u30af\u30b9\u3067\u5b9a\u7fa9\u3057\u305f\u7bc4\u56f2\uff09\u3092VBA\u304b\u3089Range(\"SalesData\")\u306e\u3088\u3046\u306b\u53c2\u7167\u3059\u308b\u3068\u304d\u3001\u305d\u306e\u540d\u524d\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u306b\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u307e\u305f\u3001\u30c6\u30fc\u30d6\u30eb\uff08ListObject\uff09\u306e\u53c2\u7167\u3067\u3082\u540c\u69d8\u306e\u30a8\u30e9\u30fc\u304c\u51fa\u307e\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u540d\u524d\u4ed8\u304d\u7bc4\u56f2\u306e\u30a8\u30e9\u30fc1004\u5bfe\u7b56\nSub NamedRangeError()\n    &#x27; === \u30a8\u30e9\u30fc\u304c\u51fa\u308b\u30d1\u30bf\u30fc\u30f3 ===\n    &#x27; Range(&quot;SalesData&quot;).Value  \u2190 \u540d\u524d&quot;SalesData&quot;\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u306a\u3044\u3068\u30a8\u30e9\u30fc1004\n\n    &#x27; === \u89e3\u6c7a\u7b561: \u540d\u524d\u304c\u5b58\u5728\u3059\u308b\u304b\u78ba\u8a8d\u3059\u308b\u95a2\u6570 ===\n    Debug.Print NameExists(&quot;SalesData&quot;, ThisWorkbook)  &#x27; True\/False\n\n    &#x27; === \u89e3\u6c7a\u7b562: \u4e8b\u524d\u78ba\u8a8d\u3057\u3066\u304b\u3089\u4f7f\u3046 ===\n    If NameExists(&quot;SalesData&quot;, ThisWorkbook) Then\n        Dim rng As Range\n        Set rng = ThisWorkbook.Names(&quot;SalesData&quot;).RefersToRange\n        Debug.Print &quot;SalesData: &quot; &amp; rng.Address\n        rng.Interior.Color = RGB(255, 255, 0)  &#x27; \u9ec4\u8272\u306b\u3059\u308b\n    Else\n        MsgBox &quot;\u540d\u524d\u4ed8\u304d\u7bc4\u56f2\u300cSalesData\u300d\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u305b\u3093&quot;, vbExclamation\n    End If\nEnd Sub\n\n&#x27; \u540d\u524d\u4ed8\u304d\u7bc4\u56f2\u306e\u5b58\u5728\u78ba\u8a8d\u95a2\u6570\nFunction NameExists(namedRange As String, wb As Workbook) As Boolean\n    Dim nm As Name\n    On Error Resume Next\n    Set nm = wb.Names(namedRange)\n    On Error GoTo 0\n    NameExists = Not (nm Is Nothing)\nEnd Function<\/pre>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">7-1. \u30c6\u30fc\u30d6\u30eb\uff08ListObject\uff09\u306e\u53c2\u7167\u30a8\u30e9\u30fc<\/h3>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u30c6\u30fc\u30d6\u30eb\uff08ListObject\uff09\u306e\u5b89\u5168\u306a\u53c2\u7167\nSub ListObjectSafeAccess()\n    Dim ws As Worksheet\n    Set ws = ThisWorkbook.Sheets(&quot;Sheet1&quot;)\n\n    Const TABLE_NAME As String = &quot;SalesTable&quot;\n\n    &#x27; \u30c6\u30fc\u30d6\u30eb\u304c\u5b58\u5728\u3059\u308b\u304b\u78ba\u8a8d\n    Dim lo As ListObject\n    On Error Resume Next\n    Set lo = ws.ListObjects(TABLE_NAME)\n    On Error GoTo 0\n\n    If lo Is Nothing Then\n        MsgBox &quot;\u30c6\u30fc\u30d6\u30eb\u300c&quot; &amp; TABLE_NAME &amp; &quot;\u300d\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3002&quot; &amp; vbCrLf &amp; _\n               &quot;Sheet1\u306b\u305d\u306e\u30c6\u30fc\u30d6\u30eb\u304c\u5b58\u5728\u3059\u308b\u304b\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;, vbExclamation\n        Exit Sub\n    End If\n\n    &#x27; \u30c6\u30fc\u30d6\u30eb\u306e\u64cd\u4f5c\n    Debug.Print &quot;\u30c6\u30fc\u30d6\u30eb\u884c\u6570: &quot; &amp; lo.ListRows.Count\n    Debug.Print &quot;\u30c6\u30fc\u30d6\u30eb\u5217\u6570: &quot; &amp; lo.ListColumns.Count\n\n    &#x27; \u7279\u5b9a\u5217\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\uff08\u5217\u540d\u3067\u6307\u5b9a\uff09\n    Dim col As ListColumn\n    On Error Resume Next\n    Set col = lo.ListColumns(&quot;\u58f2\u4e0a\u91d1\u984d&quot;)\n    On Error GoTo 0\n\n    If col Is Nothing Then\n        MsgBox &quot;\u5217\u300c\u58f2\u4e0a\u91d1\u984d\u300d\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093&quot;, vbExclamation\n        Exit Sub\n    End If\n\n    Debug.Print &quot;\u58f2\u4e0a\u91d1\u984d\u5217\u306e\u30c7\u30fc\u30bf\u7bc4\u56f2: &quot; &amp; col.DataBodyRange.Address\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<div style=\"background:#f0fdf4;border:1px solid #22c55e;border-radius:8px;padding:20px 24px;margin:24px 0;\">\n  <div style=\"display:flex;align-items:center;gap:8px;margin-bottom:12px;\">\n    <span style=\"font-size:18px;\">&#128161;<\/span>\n    <strong style=\"color:#16a34a;font-size:15px;\">\u540d\u524d\u4ed8\u304d\u7bc4\u56f2\u306f\u30d6\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\u3068\u30b7\u30fc\u30c8\u30b9\u30b3\u30fc\u30d7\u306e\u4e21\u65b9\u304c\u3042\u308b<\/strong>\n  <\/div>\n  <p style=\"margin:0;font-size:15px;line-height:1.8;color:#333;\">Excel\u306e\u540d\u524d\u4ed8\u304d\u7bc4\u56f2\u306f\u300c\u30d6\u30c3\u30af\u5168\u4f53\u3067\u6709\u52b9\uff08\u30d6\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\uff09\u300d\u3068\u300c\u7279\u5b9a\u30b7\u30fc\u30c8\u3067\u306e\u307f\u6709\u52b9\uff08\u30b7\u30fc\u30c8\u30b9\u30b3\u30fc\u30d7\uff09\u300d\u306e2\u7a2e\u985e\u304c\u3042\u308a\u307e\u3059\u3002\u30b7\u30fc\u30c8\u30b9\u30b3\u30fc\u30d7\u306e\u540d\u524d\u306fRange(\"Sheet1!SalesData\")\u306e\u3088\u3046\u306b\u30b7\u30fc\u30c8\u540d\u3092\u30d7\u30ec\u30d5\u30a3\u30c3\u30af\u30b9\u306b\u4ed8\u3051\u3066\u53c2\u7167\u3057\u307e\u3059\u3002\u5225\u306e\u30b7\u30fc\u30c8\u304b\u3089\u30d6\u30c3\u30af\u30b9\u30b3\u30fc\u30d7\u306e\u540d\u524d\u3092\u53c2\u7167\u3057\u3066\u3082\u52d5\u304d\u307e\u3059\u304c\u3001\u30b7\u30fc\u30c8\u30b9\u30b3\u30fc\u30d7\u306f\u540c\u3058\u30b7\u30fc\u30c8\u5185\u304b\u3089\u3057\u304b\u76f4\u63a5\u53c2\u7167\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<\/div>\n\n\n<div style=\"margin:48px 0 8px;display:flex;gap:12px;justify-content:center;flex-wrap:wrap;\"><a href=\"https:\/\/aikanri.genai-ai.co.jp\/seminar2-blog\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_content=cc-vba-error-1004&#038;blog_slug=cc-vba-error-1004\" target=\"_blank\" rel=\"noopener\" aria-label=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff08\u7121\u6599\u30fb1on1\u30fb60\u5206\uff09\u306e\u4e88\u7d04\u753b\u9762\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_seminar_claude_code_2026.jpg\" alt=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff5c\u7d4c\u55b6\u8005\u30fb\u4f1a\u793e\u5f79\u54e1\u5c02\u7528 1on1 60\u5206 \u7121\u6599\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_campaign=cc-vba-error-1004&#038;utm_content=h2-banner-kanri\" target=\"_blank\" rel=\"noopener\" aria-label=\"AI\u9b3c\u7ba1\u7406 \u516c\u5f0f\u30b5\u30a4\u30c8\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_blog_1to1.jpg\" alt=\"Claude Code\u3092\u7d4c\u55b6\u306b\u6d3b\u304b\u3057\u305f\u3044\u65b9\u3078 \u2014 AI\u9b3c\u7ba1\u7406\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><\/div>\n\n\n<div id=\"sec-08\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">08<\/span>\n  <span class=\"section-label\" style=\"display:block;\">CAUSE 7: INDEX OUT OF RANGE<\/span>\n  <span class=\"section-title\" style=\"display:block;\">\u539f\u56e07\uff1a\u884c\u30fb\u5217\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304c0\u4ee5\u4e0b\u307e\u305f\u306f\u4e0a\u9650\u8d85<\/span>\n  <span class=\"section-desc\">Cells(row, col)\u306e\u6709\u52b9\u7bc4\u56f2\u30fb\u52d5\u7684\u8a08\u7b97\u3067\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u691c\u8a3c<\/span>\n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Cells(\u884c, \u5217)\u3067\u6307\u5b9a\u3059\u308b\u884c\u756a\u53f7\u30fb\u5217\u756a\u53f7\u304c\u300c0\u4ee5\u4e0b\u300d\u307e\u305f\u306f\u300cExcel\u306e\u6700\u5927\u5024\uff08\u884c:1,048,576\u3001\u5217:16,384\uff09\u3092\u8d85\u3048\u308b\u300d\u5834\u5408\u306b\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3057\u307e\u3059\u3002\u7279\u306b\u300c\u30eb\u30fc\u30d7\u30ab\u30a6\u30f3\u30bf\u3084\u8a08\u7b97\u7d50\u679c\u304c\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u4f7f\u308f\u308c\u3066\u3044\u3066\u3001\u4f55\u304b\u306e\u6761\u4ef6\u30670\u3084\u8ca0\u306e\u5024\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u300d\u30b1\u30fc\u30b9\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<table>\n<thead><tr><th>\u7bc4\u56f2\u30c1\u30a7\u30c3\u30af<\/th><th>Excel\u306e\u4e0a\u9650\u5024<\/th><th>\u78ba\u8a8d\u65b9\u6cd5<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>\u6700\u5927\u884c\u6570<\/td><td>1,048,576\u884c\uff082^20\uff09<\/td><td>Rows.Count \u3067\u53d6\u5f97\uff08\u30d0\u30fc\u30b8\u30e7\u30f3\u975e\u4f9d\u5b58\uff09<\/td><\/tr>\n<tr><td>\u6700\u5927\u5217\u6570<\/td><td>16,384\u5217\uff082^14 = XFD\u5217\uff09<\/td><td>Columns.Count \u3067\u53d6\u5f97<\/td><\/tr>\n<tr><td>\u6700\u5c0f\u884c\u30fb\u5217<\/td><td>1\uff080\u4ee5\u4e0b\u306fNG\uff09<\/td><td>If row < 1 Or row > Rows.Count Then<\/td><\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u7bc4\u56f2\u8d85\u904e\u306e\u30a8\u30e9\u30fc1004\u5bfe\u7b56\nSub IndexRangeCheck()\n    &#x27; === \u3088\u304f\u3042\u308b\u539f\u56e0: \u8a08\u7b97\u7d50\u679c\u304c0\u3084\u8ca0\u306b\u306a\u308b ===\n    Dim lastRow As Long\n    lastRow = Cells(Rows.Count, 1).End(xlUp).Row  &#x27; \u30c7\u30fc\u30bf\u306e\u6700\u7d42\u884c\n\n    &#x27; \u30c7\u30fc\u30bf\u304c\u306a\u3044\u5834\u5408lastRow\u306f1\uff081\u884c\u76ee\u304c\u7a7a\u3067\u30821\u304c\u8fd4\u308b\u5834\u5408\u304c\u3042\u308b\uff09\n    Debug.Print &quot;lastRow: &quot; &amp; lastRow\n\n    &#x27; \u30d8\u30c3\u30c0\u30fc\u884c\u304c\u3042\u3063\u30662\u884c\u76ee\u304b\u3089\u30c7\u30fc\u30bf\u306e\u5834\u5408\u3001\u30c7\u30fc\u30bf\u304c1\u4ef6\u3082\u306a\u3044\u3068startRow &gt; lastRow\u306b\u306a\u308b\n    Dim startRow As Long\n    startRow = 2  &#x27; 2\u884c\u76ee\u304b\u3089\u30c7\u30fc\u30bf\n    If startRow &gt; lastRow Then\n        MsgBox &quot;\u51e6\u7406\u5bfe\u8c61\u306e\u30c7\u30fc\u30bf\u304c\u3042\u308a\u307e\u305b\u3093&quot;, vbInformation\n        Exit Sub\n    End If\n\n    &#x27; \u30eb\u30fc\u30d7\u3067\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u691c\u8a3c\n    Dim r As Long\n    For r = startRow To lastRow\n        &#x27; \u884c\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304c\u6709\u52b9\u7bc4\u56f2\u304b\u78ba\u8a8d\uff08\u5ff5\u306e\u305f\u3081\uff09\n        If r &lt; 1 Or r &gt; Rows.Count Then\n            Debug.Print &quot;\u4e0d\u6b63\u306a\u884c\u30a4\u30f3\u30c7\u30c3\u30af\u30b9: &quot; &amp; r\n            Exit For\n        End If\n\n        &#x27; \u5217\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u8a08\u7b97\u304c\u3042\u308b\u5834\u5408\u3082\u540c\u69d8\u306b\u78ba\u8a8d\n        Dim colOffset As Long\n        colOffset = 3  &#x27; \u4f55\u3089\u304b\u306e\u8a08\u7b97\n\n        Dim targetCol As Long\n        targetCol = colOffset  &#x27; \u3053\u306e\u5024\u304c0\u4ee5\u4e0b\u306b\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u5834\u5408\n\n        If targetCol &lt; 1 Or targetCol &gt; Columns.Count Then\n            Debug.Print &quot;\u4e0d\u6b63\u306a\u5217\u30a4\u30f3\u30c7\u30c3\u30af\u30b9: &quot; &amp; targetCol &amp; &quot; (\u884c=&quot; &amp; r &amp; &quot;)&quot;\n            GoTo NextRow\n        End If\n\n        Cells(r, targetCol).Value = &quot;\u51e6\u7406\u6e08&quot;\nNextRow:\n    Next r\n\n    MsgBox &quot;\u51e6\u7406\u5b8c\u4e86&quot;\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u691c\u8a3c\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u95a2\u6570\n&#x27; \u5b89\u5168\u306bCells\u3092\u53c2\u7167\u3059\u308b\u305f\u3081\u306e\u30e9\u30c3\u30d1\u30fc\u95a2\u6570\nFunction SafeCell(ws As Worksheet, row As Long, col As Long) As Range\n    If row &lt; 1 Or row &gt; ws.Rows.Count Or col &lt; 1 Or col &gt; ws.Columns.Count Then\n        Debug.Print &quot;SafeCell: \u7121\u52b9\u306a\u30a4\u30f3\u30c7\u30c3\u30af\u30b9 (row=&quot; &amp; row &amp; &quot;, col=&quot; &amp; col &amp; &quot;)&quot;\n        Set SafeCell = Nothing\n        Exit Function\n    End If\n    Set SafeCell = ws.Cells(row, col)\nEnd Function\n\n&#x27; \u4f7f\u3044\u65b9\nSub UseSafeCell()\n    Dim ws As Worksheet\n    Set ws = ActiveSheet\n\n    Dim r As Long\n    Dim c As Long\n    &#x27; \u4f55\u3089\u304b\u306e\u8a08\u7b97\u3067r\u30fbc\u304c\u6c42\u307e\u308b\n    r = 5\n    c = 0  &#x27; \u2190 \u8aa4\u3063\u30660\u306b\u306a\u3063\u3066\u3044\u308b\u30b1\u30fc\u30b9\n\n    Dim cell As Range\n    Set cell = SafeCell(ws, r, c)\n\n    If cell Is Nothing Then\n        MsgBox &quot;\u7121\u52b9\u306a\u30bb\u30eb\u4f4d\u7f6e (r=&quot; &amp; r &amp; &quot;, c=&quot; &amp; c &amp; &quot;)&quot;, vbCritical\n        Exit Sub\n    End If\n\n    cell.Value = &quot;\u30c6\u30b9\u30c8&quot;\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<div class=\"balloon-wrap is-right\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/yamazaki-avatar.png\" alt=\"AI\u9b3c\u7ba1\u7406\u5c71\u5d0e\">\n    <span class=\"balloon-name\">AI\u9b3c\u7ba1\u7406\u5c71\u5d0e<\/span>\n  <\/div>\n  <div class=\"balloon-body\">\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u8d85\u904e\u30a8\u30e9\u30fc\u306e\u591a\u304f\u306f\u300cEnd(xlUp)\u3067lastRow\u3092\u53d6\u5f97\u3057\u305f\u304c\u3001\u30b7\u30fc\u30c8\u304c\u7a7a\u3060\u3063\u305f\u305f\u30811\u304c\u8fd4\u3063\u3066\u304d\u305f\u300d\u300c\u914d\u5217\u3084\u8f9e\u66f8\u304b\u3089\u8a08\u7b97\u3057\u305f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u304c\u671f\u5f85\u3068\u9055\u3046\u5024\u306b\u306a\u3063\u305f\u300d\u30b1\u30fc\u30b9\u3067\u3059\u3002Debug.Print\u3067\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u5b9f\u969b\u306e\u5024\u3092\u51fa\u529b\u3057\u3066\u78ba\u8a8d\u3059\u308b\u3053\u3068\u304c\u6700\u901f\u306e\u89e3\u6c7a\u7b56\u3067\u3059\u3002<\/div>\n<\/div>\n\n\n<div style=\"margin:48px 0 8px;display:flex;gap:12px;justify-content:center;flex-wrap:wrap;\"><a href=\"https:\/\/aikanri.genai-ai.co.jp\/seminar2-blog\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_content=cc-vba-error-1004&#038;blog_slug=cc-vba-error-1004\" target=\"_blank\" rel=\"noopener\" aria-label=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff08\u7121\u6599\u30fb1on1\u30fb60\u5206\uff09\u306e\u4e88\u7d04\u753b\u9762\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_seminar_claude_code_2026.jpg\" alt=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff5c\u7d4c\u55b6\u8005\u30fb\u4f1a\u793e\u5f79\u54e1\u5c02\u7528 1on1 60\u5206 \u7121\u6599\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_campaign=cc-vba-error-1004&#038;utm_content=h2-banner-kanri\" target=\"_blank\" rel=\"noopener\" aria-label=\"AI\u9b3c\u7ba1\u7406 \u516c\u5f0f\u30b5\u30a4\u30c8\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_blog_1to1.jpg\" alt=\"Claude Code\u3092\u7d4c\u55b6\u306b\u6d3b\u304b\u3057\u305f\u3044\u65b9\u3078 \u2014 AI\u9b3c\u7ba1\u7406\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><\/div>\n\n\n<div id=\"sec-09\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">09<\/span>\n  <span class=\"section-label\" style=\"display:block;\">DEBUG METHODS<\/span>\n  <span class=\"section-title\" style=\"display:block;\">\u30c7\u30d0\u30c3\u30b0\u624b\u6cd5\uff08Debug.Print\u30fb\u30d6\u30ec\u30fc\u30af\u30dd\u30a4\u30f3\u30c8\u30fb\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\uff09<\/span>\n  <span class=\"section-desc\">\u30a8\u30e9\u30fc1004\u306e\u539f\u56e0\u3092\u7d20\u65e9\u304f\u7279\u5b9a\u3059\u308b3\u3064\u306e\u30c7\u30d0\u30c3\u30b0\u30c6\u30af\u30cb\u30c3\u30af<\/span>\n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3057\u305f\u3068\u304d\u3001\u539f\u56e0\u3092\u7d20\u65e9\u304f\u7279\u5b9a\u3059\u308b\u305f\u3081\u306e\u30c7\u30d0\u30c3\u30b0\u624b\u6cd5\u30923\u3064\u7d39\u4ecb\u3057\u307e\u3059\u3002\u3053\u308c\u3089\u3092\u4f7f\u3048\u3070\u300c\u3069\u306e\u5909\u6570\u304c\u4f55\u306e\u5024\u3092\u6301\u3063\u3066\u3044\u308b\u304b\u300d\u300c\u3069\u306e\u884c\u3067\u6b62\u307e\u3063\u3066\u3044\u308b\u304b\u300d\u304c\u660e\u78ba\u306b\u306a\u308a\u3001\u539f\u56e0\u306e\u7279\u5b9a\u304c\u5927\u5e45\u306b\u901f\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">9-1. Debug.Print\u3067\u5909\u6570\u306e\u5024\u3092\u78ba\u8a8d\u3059\u308b<\/h3>\n\n\n\n<div style=\"background:#f8f9fa;border-left:4px solid #6b7280;border-radius:0 8px 8px 0;padding:16px 20px;margin:20px 0;\">\n  <p style=\"margin:0 0 4px;font-size:13px;font-weight:700;color:#6b7280;letter-spacing:1px;\">&#128218; \u7528\u8a9e\u89e3\u8aac<\/p>\n  <p style=\"margin:0;font-size:15px;line-height:1.7;\"><strong>Debug.Print\uff08\u30c7\u30d0\u30c3\u30b0\u30fb\u30d7\u30ea\u30f3\u30c8\uff09<\/strong>\uff1aVBA\u306e\u7d44\u307f\u8fbc\u307f\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3002Debug.Print \u5f0f \u3068\u66f8\u304f\u3068\u3001\u305d\u306e\u5f0f\u306e\u5024\u304c\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\uff08VBA\u30a8\u30c7\u30a3\u30bf\u4e0b\u90e8\u306e\u30d1\u30cd\u30eb\uff09\u306b\u51fa\u529b\u3055\u308c\u307e\u3059\u3002MsgBox\u3068\u9055\u3044\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u6b62\u307e\u3089\u306a\u3044\u305f\u3081\u3001\u30eb\u30fc\u30d7\u5185\u306e\u5909\u6570\u5024\u306e\u8ffd\u8de1\u306b\u9069\u3057\u3066\u3044\u307e\u3059\u3002\u672c\u756a\u524d\u306b\u524a\u9664\u3059\u308b\u304b\u3001\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u3066\u7121\u52b9\u5316\u3057\u307e\u3059\u3002<\/p>\n<\/div>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; Debug.Print\u306e\u6d3b\u7528\u4f8b\uff08\u30a8\u30e9\u30fc1004\u306e\u30c7\u30d0\u30c3\u30b0\uff09\nSub DebugWithPrint()\n    Dim wb As Workbook\n    Dim ws As Worksheet\n    Dim filePath As String\n    Dim sheetName As String\n\n    filePath = &quot;C:\\Data\\report.xlsx&quot;\n    sheetName = &quot;\u96c6\u8a08&quot;\n\n    &#x27; ===== \u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u3068Dir\u7d50\u679c\u3092\u78ba\u8a8d =====\n    Debug.Print &quot;=== \u30d5\u30a1\u30a4\u30eb\u78ba\u8a8d ===&quot;\n    Debug.Print &quot;filePath: [&quot; &amp; filePath &amp; &quot;]&quot;\n    Debug.Print &quot;Dir result: [&quot; &amp; Dir(filePath) &amp; &quot;]&quot;  &#x27; &quot;&quot;\u306a\u3089\u30d5\u30a1\u30a4\u30eb\u306a\u3057\n\n    If Dir(filePath) = &quot;&quot; Then\n        Debug.Print &quot;\u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3057\u307e\u305b\u3093&quot;\n        Exit Sub\n    End If\n\n    Set wb = Workbooks.Open(filePath)\n\n    &#x27; ===== \u30d6\u30c3\u30af\u5185\u306e\u30b7\u30fc\u30c8\u4e00\u89a7\u3092\u78ba\u8a8d =====\n    Debug.Print &quot;=== \u30b7\u30fc\u30c8\u4e00\u89a7 ===&quot;\n    Dim i As Integer\n    For i = 1 To wb.Sheets.Count\n        Debug.Print &quot;  \u30b7\u30fc\u30c8&quot; &amp; i &amp; &quot;: [&quot; &amp; wb.Sheets(i).Name &amp; &quot;]&quot;\n    Next i\n\n    &#x27; ===== \u76ee\u7684\u306e\u30b7\u30fc\u30c8\u304c\u5b58\u5728\u3059\u308b\u304b\u78ba\u8a8d =====\n    Debug.Print &quot;=== \u30b7\u30fc\u30c8\u5b58\u5728\u78ba\u8a8d ===&quot;\n    Debug.Print &quot;sheetName: [&quot; &amp; sheetName &amp; &quot;]&quot;\n    Debug.Print &quot;SheetExists: &quot; &amp; SheetExists(sheetName, wb)\n\n    If Not SheetExists(sheetName, wb) Then\n        Debug.Print &quot;\u30b7\u30fc\u30c8\u304c\u5b58\u5728\u3057\u307e\u305b\u3093&quot;\n        wb.Close False\n        Exit Sub\n    End If\n\n    Set ws = wb.Sheets(sheetName)\n\n    &#x27; ===== \u6700\u7d42\u884c\u30fb\u5217\u3092\u78ba\u8a8d =====\n    Dim lastRow As Long\n    Dim lastCol As Long\n    lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row\n    lastCol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column\n    Debug.Print &quot;=== \u30c7\u30fc\u30bf\u7bc4\u56f2 ===&quot;\n    Debug.Print &quot;lastRow: &quot; &amp; lastRow &amp; &quot;, lastCol: &quot; &amp; lastCol\n\n    wb.Close False\n    Debug.Print &quot;=== \u30c7\u30d0\u30c3\u30b0\u5b8c\u4e86 ===&quot;\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">9-2. \u30d6\u30ec\u30fc\u30af\u30dd\u30a4\u30f3\u30c8\u3067\u30b9\u30c6\u30c3\u30d7\u5b9f\u884c<\/h3>\n\n\n\n<div style=\"background:#fafafa;border-radius:8px;padding:16px 20px;margin:16px 0;border-left:4px solid #dc2626;\">\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u30d6\u30ec\u30fc\u30af\u30dd\u30a4\u30f3\u30c8\u306e\u8a2d\u5b9a<\/strong>\uff1aVBA\u30a8\u30c7\u30a3\u30bf\u3067\u6b62\u3081\u305f\u3044\u884c\u306e\u5de6\u7aef\u30b0\u30ec\u30fc\u30d0\u30fc\u3092\u30af\u30ea\u30c3\u30af\uff08\u8d64\u4e38\u304c\u8868\u793a\u3055\u308c\u308b\uff09<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>F5\u3067\u5b9f\u884c<\/strong>\uff1a\u30d6\u30ec\u30fc\u30af\u30dd\u30a4\u30f3\u30c8\u306e\u624b\u524d\u307e\u3067\u5b9f\u884c\u3057\u3066\u81ea\u52d5\u505c\u6b62<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>F8\u3067\u30b9\u30c6\u30c3\u30d7\u5b9f\u884c<\/strong>\uff1a\u505c\u6b62\u3057\u305f\u72b6\u614b\u304b\u3089F8\u3092\u62bc\u3059\u30681\u884c\u305a\u3064\u5b9f\u884c\u3067\u304d\u308b\u3002\u5909\u6570\u306b\u30ab\u30fc\u30bd\u30eb\u3092\u5408\u308f\u305b\u308b\u3068\u73fe\u5728\u5024\u304c\u8868\u793a\u3055\u308c\u308b<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u30ed\u30fc\u30ab\u30eb\u30a6\u30a3\u30f3\u30c9\u30a6<\/strong>\uff1a\u300c\u8868\u793a\u300d\u2192\u300c\u30ed\u30fc\u30ab\u30eb\u30a6\u30a3\u30f3\u30c9\u30a6\u300d\u3067\u73fe\u5728\u306e\u5168\u5909\u6570\u306e\u5024\u3092\u4e00\u89a7\u8868\u793a<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u30a6\u30a9\u30c3\u30c1\u30a6\u30a3\u30f3\u30c9\u30a6<\/strong>\uff1a\u7279\u5b9a\u306e\u5909\u6570\u30fb\u5f0f\u3092\u767b\u9332\u3057\u3066\u5024\u306e\u5909\u5316\u3092\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u76e3\u8996\u3067\u304d\u308b<\/span><\/div>\n\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">9-3. \u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\u3067\u5bfe\u8a71\u7684\u306b\u78ba\u8a8d<\/h3>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\u3067\u306e\u78ba\u8a8d\u65b9\u6cd5\uff08?\u30b3\u30de\u30f3\u30c9\uff09\n\n&#x27; \u30d6\u30ec\u30fc\u30af\u30dd\u30a4\u30f3\u30c8\u3067\u6b62\u307e\u3063\u3066\u3044\u308b\u3068\u304d\u3001\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\uff08Ctrl+G\uff09\u3067\n&#x27; \u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5165\u529b\u3057\u3066\u5909\u6570\u306e\u5024\u3084\u5f0f\u306e\u7d50\u679c\u3092\u78ba\u8a8d\u3067\u304d\u308b\n\n&#x27; ? ws.Name               \u2190 ws\u304c\u4f55\u306e\u30b7\u30fc\u30c8\u304b\u78ba\u8a8d\n&#x27; ? ws.ProtectContents    \u2190 \u30b7\u30fc\u30c8\u304c\u4fdd\u8b77\u3055\u308c\u3066\u3044\u308b\u304b\n&#x27; ? Dir(&quot;C:\\Data\\report.xlsx&quot;)  \u2190 \u30d5\u30a1\u30a4\u30eb\u304c\u5b58\u5728\u3059\u308b\u304b\n&#x27; ? Err.Number            \u2190 \u76f4\u8fd1\u306e\u30a8\u30e9\u30fc\u756a\u53f7\n&#x27; ? Err.Description       \u2190 \u76f4\u8fd1\u306e\u30a8\u30e9\u30fc\u306e\u8aac\u660e\n\n&#x27; \u30b3\u30fc\u30c9\u306e\u5b9f\u884c\u4e2d\u3067\u3082\uff08\u30d6\u30ec\u30fc\u30af\u30dd\u30a4\u30f3\u30c8\u505c\u6b62\u4e2d\u306b\uff09\u76f4\u63a5\u4ee3\u5165\u3057\u3066\u52d5\u4f5c\u78ba\u8a8d\u3082\u3067\u304d\u308b\n&#x27; ws.Cells(1,1).Value = &quot;\u30c6\u30b9\u30c8&quot;  \u2190 \u76f4\u63a5\u30bb\u30eb\u306b\u5024\u3092\u8a2d\u5b9a\u3057\u3066\u6319\u52d5\u78ba\u8a8d\n\n&#x27; ===== Debug.Assert\uff08\u6761\u4ef6\u304cFalse\u306e\u3068\u304d\u81ea\u52d5\u505c\u6b62\uff09=====\nSub DebugAssertExample()\n    Dim row As Long\n    row = 0  &#x27; \u2190 \u672c\u6765\u306f1\u4ee5\u4e0a\u306e\u5024\u306b\u306a\u308b\u306f\u305a\u304c0\u306b\u306a\u3063\u305f\u5834\u5408\n\n    &#x27; Debug.Assert\u3067\u7570\u5e38\u5024\u3092\u5373\u6642\u691c\u77e5\uff08False\u306e\u3068\u304d\u81ea\u52d5\u30d6\u30ec\u30fc\u30af\uff09\n    Debug.Assert row &gt;= 1  &#x27; row\u304c0\u306e\u3068\u304d\u3053\u3053\u3067\u6b62\u307e\u308b\uff08\u958b\u767a\u6642\u306e\u691c\u8a3c\u306b\u6709\u52b9\uff09\n\n    Cells(row, 1).Value = &quot;\u51e6\u7406&quot;  &#x27; \u2190 row\u304c0\u3060\u3068\u30a8\u30e9\u30fc1004\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<div class=\"balloon-wrap\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/ceo-sugasawa.jpg\" alt=\"\u4ee3\u8868\u83c5\u6fa4\">\n    <span class=\"balloon-name\">\u4ee3\u8868\u83c5\u6fa4<\/span>\n  <\/div>\n  <div class=\"balloon-body\">Debug.Print\u306e\u51fa\u529b\u306f\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\u306b\u3059\u3079\u3066\u6b8b\u308b\u305f\u3081\u3001\u5f8c\u304b\u3089\u898b\u8fd4\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u72b6\u6cc1\u3092\u518d\u73fe\u3059\u308b\u3068\u304d\u306f\u3001Debug.Print\u3067\u5168\u5909\u6570\u306e\u5024\u3092\u51fa\u529b\u3059\u308b\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u304b\u3089\u5b9f\u884c\u3059\u308b\u3068\u3001\u300c\u3069\u306e\u5909\u6570\u304c\u539f\u56e0\u304b\u300d\u3092\u52b9\u7387\u7684\u306b\u7d5e\u308a\u8fbc\u3081\u307e\u3059\u3002<\/div>\n<\/div>\n\n\n<div style=\"margin:48px 0 8px;display:flex;gap:12px;justify-content:center;flex-wrap:wrap;\"><a href=\"https:\/\/aikanri.genai-ai.co.jp\/seminar2-blog\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_content=cc-vba-error-1004&#038;blog_slug=cc-vba-error-1004\" target=\"_blank\" rel=\"noopener\" aria-label=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff08\u7121\u6599\u30fb1on1\u30fb60\u5206\uff09\u306e\u4e88\u7d04\u753b\u9762\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_seminar_claude_code_2026.jpg\" alt=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff5c\u7d4c\u55b6\u8005\u30fb\u4f1a\u793e\u5f79\u54e1\u5c02\u7528 1on1 60\u5206 \u7121\u6599\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_campaign=cc-vba-error-1004&#038;utm_content=h2-banner-kanri\" target=\"_blank\" rel=\"noopener\" aria-label=\"AI\u9b3c\u7ba1\u7406 \u516c\u5f0f\u30b5\u30a4\u30c8\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_blog_1to1.jpg\" alt=\"Claude Code\u3092\u7d4c\u55b6\u306b\u6d3b\u304b\u3057\u305f\u3044\u65b9\u3078 \u2014 AI\u9b3c\u7ba1\u7406\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><\/div>\n\n\n<div id=\"sec-10\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">10<\/span>\n  <span class=\"section-label\" style=\"display:block;\">ERROR HANDLING<\/span>\n  <span class=\"section-title\" style=\"display:block;\">\u30a8\u30e9\u30fc\u51e6\u7406\u3067Error 1004\u3092\u30ad\u30e3\u30c3\u30c1\u3059\u308b<\/span>\n  <span class=\"section-desc\">On Error GoTo + Select Case 1004\u306e\u5b9f\u8df5\u30d1\u30bf\u30fc\u30f3<\/span>\n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u64cd\u4f5c\u3092On Error GoTo\u3067\u56f2\u307f\u3001ErrorHandler\u5185\u3067Err.Number = 1004\u3068\u3057\u3066\u51e6\u7406\u3059\u308b\u3053\u3068\u3067\u3001\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3082\u9069\u5207\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u3057\u3066\u51e6\u7406\u3092\u7d9a\u884c\u307e\u305f\u306f\u7d42\u4e86\u3067\u304d\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u30a8\u30e9\u30fc1004\u306f\u539f\u56e0\u304c\u591a\u69d8\u306a\u305f\u3081\u3001\u300c1004\u3092\u4e00\u5f8b\u306b\u30ad\u30e3\u30c3\u30c1\u3057\u3066\u7121\u8996\u3059\u308b\u300d\u306e\u306f\u5371\u967a\u3067\u3059\u3002\u5fc5\u305a\u300c\u3069\u3093\u306a1004\u304b\u300d\u3092\u7279\u5b9a\u3057\u3066\u9069\u5207\u306b\u5bfe\u51e6\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; \u30a8\u30e9\u30fc1004\u3092\u30ad\u30e3\u30c3\u30c1\u3057\u3066\u539f\u56e0\u5225\u306b\u5bfe\u51e6\u3059\u308b\u30d1\u30bf\u30fc\u30f3\nSub CatchError1004()\n    Dim filePath As String\n    Dim ws As Worksheet\n    Dim wb As Workbook\n\n    filePath = &quot;C:\\Data\\monthly.xlsx&quot;\n\n    On Error GoTo ErrorHandler\n\n    &#x27; === \u30b9\u30c6\u30c3\u30d71: \u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f ===\n    Set wb = Workbooks.Open(filePath)\n\n    &#x27; === \u30b9\u30c6\u30c3\u30d72: \u30b7\u30fc\u30c8\u3092\u53d6\u5f97 ===\n    Set ws = wb.Sheets(&quot;\u96c6\u8a08&quot;)\n\n    &#x27; === \u30b9\u30c6\u30c3\u30d73: \u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u3080 ===\n    ws.Cells(1, 1).Value = &quot;\u51e6\u7406\u6e08\u307f&quot;\n    ws.Cells(1, 2).Value = Now()\n\n    &#x27; === \u30b9\u30c6\u30c3\u30d74: \u4fdd\u5b58\u3057\u3066\u9589\u3058\u308b ===\n    wb.Save\n    wb.Close\n\n    MsgBox &quot;\u51e6\u7406\u304c\u6b63\u5e38\u306b\u5b8c\u4e86\u3057\u307e\u3057\u305f&quot;, vbInformation\n    Exit Sub\n\nErrorHandler:\n    Dim errNum As Long\n    Dim errDesc As String\n    errNum = Err.Number\n    errDesc = Err.Description\n\n    &#x27; \u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\uff08\u30a8\u30e9\u30fc\u304c\u3042\u3063\u3066\u3082\u958b\u3044\u305f\u30d6\u30c3\u30af\u306f\u9589\u3058\u308b\uff09\n    On Error Resume Next\n    If Not wb Is Nothing Then wb.Close False\n    On Error GoTo 0\n\n    &#x27; \u30a8\u30e9\u30fc\u756a\u53f7\u5225\u306e\u5bfe\u51e6\n    Select Case errNum\n        Case 1004\n            &#x27; 1004\u306f\u591a\u69d8\u306a\u306e\u3067\u8ffd\u52a0\u60c5\u5831\u3092Debug.Print\u3067\u78ba\u8a8d\n            Debug.Print &quot;Error 1004: &quot; &amp; errDesc\n            If InStr(errDesc, &quot;protected&quot;) &gt; 0 Or InStr(errDesc, &quot;\u4fdd\u8b77&quot;) &gt; 0 Then\n                MsgBox &quot;\u30b7\u30fc\u30c8\u304c\u4fdd\u8b77\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u30b7\u30fc\u30c8\u306e\u4fdd\u8b77\u3092\u89e3\u9664\u3057\u3066\u304b\u3089\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;, _\n                       vbExclamation, &quot;\u30b7\u30fc\u30c8\u4fdd\u8b77\u30a8\u30e9\u30fc&quot;\n            ElseIf InStr(errDesc, &quot;not find&quot;) &gt; 0 Or InStr(errDesc, &quot;\u898b\u3064\u304b\u308a\u307e\u305b\u3093&quot;) &gt; 0 Then\n                MsgBox &quot;\u30b7\u30fc\u30c8\u307e\u305f\u306f\u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093: &quot; &amp; vbCrLf &amp; errDesc, _\n                       vbCritical, &quot;\u5b58\u5728\u30a8\u30e9\u30fc&quot;\n            Else\n                MsgBox &quot;Excel\u64cd\u4f5c\u30a8\u30e9\u30fc\uff081004\uff09: &quot; &amp; vbCrLf &amp; errDesc &amp; vbCrLf &amp; _\n                       &quot;\u64cd\u4f5c\u306e\u5185\u5bb9\u3092\u3054\u78ba\u8a8d\u304f\u3060\u3055\u3044\u3002&quot;, vbCritical, &quot;\u30a8\u30e9\u30fc1004&quot;\n            End If\n        Case 53\n            MsgBox &quot;\u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093: &quot; &amp; filePath, vbCritical, &quot;\u30d5\u30a1\u30a4\u30eb\u672a\u5b58\u5728&quot;\n        Case 9\n            MsgBox &quot;\u30b7\u30fc\u30c8\u304c\u5b58\u5728\u3057\u307e\u305b\u3093\uff08\u6dfb\u5b57\u304c\u7bc4\u56f2\u5916\uff09&quot;, vbExclamation, &quot;\u30b7\u30fc\u30c8\u672a\u5b58\u5728&quot;\n        Case 70\n            MsgBox &quot;\u30d5\u30a1\u30a4\u30eb\u304c\u4ed6\u306e\u30a2\u30d7\u30ea\u3067\u958b\u304b\u308c\u3066\u3044\u307e\u3059\u3002\u9589\u3058\u3066\u304b\u3089\u518d\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;, _\n                   vbExclamation, &quot;\u30a2\u30af\u30bb\u30b9\u62d2\u5426&quot;\n        Case Else\n            MsgBox &quot;\u4e88\u671f\u305b\u306c\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002&quot; &amp; vbCrLf &amp; _\n                   &quot;\u30a8\u30e9\u30fc\u756a\u53f7: &quot; &amp; errNum &amp; vbCrLf &amp; _\n                   &quot;\u5185\u5bb9: &quot; &amp; errDesc, vbCritical, &quot;\u30a8\u30e9\u30fc&quot;\n    End Select\nEnd Sub<\/pre>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">10-1. \u30a8\u30e9\u30fc1004\u306eDescription\u30d1\u30bf\u30fc\u30f3\u4e00\u89a7<\/h3>\n\n\n\n<table>\n<thead><tr><th>Err.Description\u306b\u542b\u307e\u308c\u308b\u6587\u5b57\u5217<\/th><th>\u539f\u56e0<\/th><th>\u5bfe\u51e6\u6cd5<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>\"protected\" \/ \"\u4fdd\u8b77\"<\/td><td>\u30b7\u30fc\u30c8\u304c\u4fdd\u8b77\u3055\u308c\u3066\u3044\u308b<\/td><td>ws.Unprotect \u2192 \u51e6\u7406 \u2192 ws.Protect<\/td><\/tr>\n<tr><td>\"not find\" \/ \"\u898b\u3064\u304b\u308a\u307e\u305b\u3093\"<\/td><td>\u30b7\u30fc\u30c8\u3084\u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u3089\u306a\u3044<\/td><td>Dir\u95a2\u6570\u30fbSheetExists\u95a2\u6570\u3067\u4e8b\u524d\u78ba\u8a8d<\/td><\/tr>\n<tr><td>\"Select method\"<\/td><td>\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306eSelect<\/td><td>Select\u3092Value\u4ee3\u5165\u306b\u5909\u66f4<\/td><\/tr>\n<tr><td>\"PasteSpecial\"<\/td><td>\u30af\u30ea\u30c3\u30d7\u30dc\u30fc\u30c9\u304c\u7a7a\u307e\u305f\u306f\u30b5\u30a4\u30ba\u4e0d\u4e00\u81f4<\/td><td>Copy\u5148\u3092\u76f4\u63a5\u6307\u5b9a\u307e\u305f\u306fRange.Value = Range.Value<\/td><\/tr>\n<tr><td>\"Cells\" \/ \"Range\"<\/td><td>\u7121\u52b9\u306a\u30a2\u30c9\u30ec\u30b9\u30fb\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u8d85\u904e<\/td><td>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e\u7bc4\u56f2\u30c1\u30a7\u30c3\u30af\u3092\u8ffd\u52a0<\/td><\/tr>\n<\/tbody>\n<\/table>\n\n\n\n<div style=\"background:#f0fdf4;border:1px solid #22c55e;border-radius:8px;padding:20px 24px;margin:24px 0;\">\n  <div style=\"display:flex;align-items:center;gap:8px;margin-bottom:12px;\">\n    <span style=\"font-size:18px;\">&#128161;<\/span>\n    <strong style=\"color:#16a34a;font-size:15px;\">\u30a8\u30e9\u30fc1004\u306eDescription\u3092\u4f7f\u3063\u305f\u5206\u5c90<\/strong>\n  <\/div>\n  <p style=\"margin:0;font-size:15px;line-height:1.8;color:#333;\">Err.Description\u306b\u306f\u82f1\u8a9e\u306e\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u5165\u308a\u307e\u3059\u3002\u5b8c\u5168\u4e00\u81f4\u3067\u306a\u304fInStr(Err.Description, \"\u30ad\u30fc\u30ef\u30fc\u30c9\") > 0\u3067\u90e8\u5206\u4e00\u81f4\u691c\u7d22\u3059\u308b\u3068\u3001\u69d8\u3005\u306a\u30d0\u30fc\u30b8\u30e7\u30f3\u30fb\u8a00\u8a9e\u8a2d\u5b9a\u306eExcel\u306b\u5bfe\u5fdc\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002\u305f\u3060\u3057\u3001Description\u306e\u30c6\u30ad\u30b9\u30c8\u306f\u30d0\u30fc\u30b8\u30e7\u30f3\u3084\u8a00\u8a9e\u306b\u3088\u3063\u3066\u5909\u308f\u308b\u5834\u5408\u304c\u3042\u308b\u305f\u3081\u3001Err.Number\u306b\u3088\u308b\u5206\u5c90\u3092\u4e3b\u4f53\u306b\u3057\u3066Description\u306f\u30b5\u30d6\u60c5\u5831\u3068\u3057\u3066\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<\/div>\n\n\n\n<div style=\"background:#1e1e1e;border-radius:8px;padding:20px 24px;margin:20px 0;overflow-x:auto;\">\n  <pre style=\"margin:0;font-family:'Courier New',monospace;font-size:13px;line-height:1.8;color:#d4d4d4;white-space:pre-wrap;\">&#x27; Claude Code\u3078\u306e\u30a8\u30e9\u30fc1004\u30c7\u30d0\u30c3\u30b0\u4f9d\u983c\u30d7\u30ed\u30f3\u30d7\u30c8\u4f8b\n&#x27; \uff08\u4ee5\u4e0b\u3092Claude Code\u306e\u30c1\u30e3\u30c3\u30c8\u306b\u8cbc\u308a\u4ed8\u3051\u3066\u4f9d\u983c\u3067\u304d\u307e\u3059\uff09\n\n&#x27;&#x27;&#x27;\n\u3053\u306eVBA\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u30a8\u30e9\u30fc1004\u304c\u767a\u751f\u3057\u307e\u3059\u3002\n\n\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u884c:\n[\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u3044\u308b\u30b3\u30fc\u30c9\u3092\u3053\u3053\u306b\u8cbc\u308b]\n\n\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8:\n\u5b9f\u884c\u6642\u30a8\u30e9\u30fc &#x27;1004&#x27; Application-defined or object-defined error\nErr.Description: [Description\u306e\u5185\u5bb9\u3092\u3053\u3053\u306b]\n\n\u3053\u306e\u3068\u304d\u5404\u5909\u6570\u306e\u5024:\n\u30fbfilePath = &quot;C:\\Data\\report.xlsx&quot;\n\u30fbsheetName = &quot;\u30c7\u30fc\u30bf&quot;\n\u30fblastRow = 0\n\n\u539f\u56e0\u306e\u7279\u5b9a\u3068\u4fee\u6b63\u65b9\u6cd5\u3092\u6559\u3048\u3066\u304f\u3060\u3055\u3044\u3002\n&#x27;&#x27;&#x27;<\/pre>\n<\/div>\n\n\n\n<div class=\"balloon-wrap is-right\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/yamazaki-avatar.png\" alt=\"AI\u9b3c\u7ba1\u7406\u5c71\u5d0e\">\n    <span class=\"balloon-name\">AI\u9b3c\u7ba1\u7406\u5c71\u5d0e<\/span>\n  <\/div>\n  <div class=\"balloon-body\">Claude Code\u306b\u30a8\u30e9\u30fc1004\u306e\u30c7\u30d0\u30c3\u30b0\u3092\u4f9d\u983c\u3059\u308b\u3068\u304d\u3001\u300c\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u884c\u300d\u300cErr.Description\u300d\u300c\u305d\u306e\u6642\u70b9\u306e\u5909\u6570\u306e\u5024\uff08Debug.Print\u3067\u53d6\u5f97\uff09\u300d\u3092\u63c3\u3048\u3066\u8cbc\u308a\u4ed8\u3051\u308b\u3068\u3001\u6b63\u78ba\u306a\u539f\u56e0\u3068\u4fee\u6b63\u30b3\u30fc\u30c9\u3092\u8fd4\u3057\u3066\u304f\u308c\u307e\u3059\u3002\u300c\u30a8\u30e9\u30fc1004\u304c\u51fa\u307e\u3057\u305f\u3001\u306a\u305c\u3067\u3059\u304b\uff1f\u300d\u3060\u3051\u3067\u306f\u60c5\u5831\u4e0d\u8db3\u3067\u539f\u56e0\u3092\u7279\u5b9a\u3067\u304d\u307e\u305b\u3093\u3002<\/div>\n<\/div>\n\n\n<div style=\"margin:48px 0 8px;display:flex;gap:12px;justify-content:center;flex-wrap:wrap;\"><a href=\"https:\/\/aikanri.genai-ai.co.jp\/seminar2-blog\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_content=cc-vba-error-1004&#038;blog_slug=cc-vba-error-1004\" target=\"_blank\" rel=\"noopener\" aria-label=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff08\u7121\u6599\u30fb1on1\u30fb60\u5206\uff09\u306e\u4e88\u7d04\u753b\u9762\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_seminar_claude_code_2026.jpg\" alt=\"Claude Code \u5b8c\u5168\u89e3\u8aac\u30bb\u30df\u30ca\u30fc\uff5c\u7d4c\u55b6\u8005\u30fb\u4f1a\u793e\u5f79\u54e1\u5c02\u7528 1on1 60\u5206 \u7121\u6599\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&#038;utm_medium=h2banner&#038;utm_campaign=cc-vba-error-1004&#038;utm_content=h2-banner-kanri\" target=\"_blank\" rel=\"noopener\" aria-label=\"AI\u9b3c\u7ba1\u7406 \u516c\u5f0f\u30b5\u30a4\u30c8\u3078\" style=\"flex:1 1 280px;max-width:360px;text-decoration:none;\"><img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/05\/cta_blog_1to1.jpg\" alt=\"Claude Code\u3092\u7d4c\u55b6\u306b\u6d3b\u304b\u3057\u305f\u3044\u65b9\u3078 \u2014 AI\u9b3c\u7ba1\u7406\" style=\"width:100%;height:auto;border-radius:8px;display:block;\"><\/a><\/div>\n\n\n<div id=\"sec-11\"><\/div>\n<h2 class=\"section-header-img\" style=\"margin:32px 0 24px;border-radius:8px;overflow:hidden;background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);padding:32px 28px;color:#fff;position:relative;border:none;border-left:none;text-align:left;\">\n  <span class=\"section-number\" style=\"display:block;\">11<\/span>\n  <span class=\"section-label\" style=\"display:block;\">CONCLUSION<\/span>\n  <span class=\"section-title\" style=\"display:block;\">\u307e\u3068\u3081<\/span>\n  <span class=\"section-desc\">\u30a8\u30e9\u30fc1004\u306e\u539f\u56e0\u30c1\u30a7\u30c3\u30af\u30ea\u30b9\u30c8\u3068\u518d\u767a\u9632\u6b62\u306e\u8a2d\u8a08\u65b9\u91dd<\/span>\n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001VBA\u5b9f\u884c\u6642\u30a8\u30e9\u30fc1004\uff08Application-defined or object-defined error\uff09\u306e7\u3064\u306e\u767a\u751f\u30d1\u30bf\u30fc\u30f3\u3092\u539f\u56e0\u30fb\u75c7\u72b6\u30fb\u89e3\u6c7a\u30b3\u30fc\u30c9\u4ed8\u304d\u3067\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002\u30a8\u30e9\u30fc1004\u304c\u591a\u69d8\u306a\u539f\u56e0\u3092\u6301\u3064\u6c4e\u7528\u30a8\u30e9\u30fc\u3067\u3042\u308b\u3053\u3068\u3092\u7406\u89e3\u3057\u305f\u4e0a\u3067\u3001\u30d1\u30bf\u30fc\u30f3\u5225\u306e\u5bfe\u51e6\u6cd5\u3092\u4f7f\u3044\u5206\u3051\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<div style=\"background:#fafafa;border-radius:8px;padding:16px 20px;margin:16px 0;border-left:4px solid #dc2626;\">\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u539f\u56e01: \u30d5\u30a1\u30a4\u30eb\u672a\u5b58\u5728<\/strong> \u2192 Dir\u95a2\u6570\u3067\u30d5\u30a1\u30a4\u30eb\u306e\u5b58\u5728\u78ba\u8a8d\u3092Workbooks.Open\u306e\u524d\u306b\u5b9f\u65bd<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u539f\u56e02: \u30b7\u30fc\u30c8\u30fb\u30bb\u30eb\u672a\u5b58\u5728<\/strong> \u2192 SheetExists\u95a2\u6570\u3067\u30b7\u30fc\u30c8\u306e\u4e8b\u524d\u78ba\u8a8d\u3001Range\u6307\u5b9a\u306e\u6dfb\u5b57\u30c1\u30a7\u30c3\u30af<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u539f\u56e03: \u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306eSelect<\/strong> \u2192 Select\u3092Value\u4ee3\u5165\u306b\u5909\u66f4\u3057\u3066Activate\u4f9d\u5b58\u3092\u306a\u304f\u3059<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u539f\u56e04: \u30b3\u30d4\u30fc\u7bc4\u56f2\u306e\u4e0d\u4e00\u81f4<\/strong> \u2192 PasteSpecial\u3092Range.Value = Range.Value\u306e\u76f4\u63a5\u4ee3\u5165\u306b\u7f6e\u304d\u63db\u3048<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u539f\u56e05: \u4fdd\u8b77\u30b7\u30fc\u30c8\u3078\u306e\u66f8\u304d\u8fbc\u307f<\/strong> \u2192 Unprotect \u2192 \u51e6\u7406 \u2192 Protect \u306e\u30d1\u30bf\u30fc\u30f3\u3092\u5fb9\u5e95<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u539f\u56e06: \u540d\u524d\u4ed8\u304d\u7bc4\u56f2\u306e\u6307\u5b9a\u30df\u30b9<\/strong> \u2192 Names\u95a2\u6570\u3067On Error Resume Next\u3092\u4f7f\u3063\u305f\u5b58\u5728\u78ba\u8a8d<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u539f\u56e07: \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u8d85\u904e<\/strong> \u2192 1\u4ee5\u4e0a\u30fbRows.Count\/Columns.Count\u4ee5\u4e0b\u306e\u7bc4\u56f2\u30c1\u30a7\u30c3\u30af<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u30c7\u30d0\u30c3\u30b0<\/strong> \u2192 Debug.Print\u30fb\u30d6\u30ec\u30fc\u30af\u30dd\u30a4\u30f3\u30c8\u30fb\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u6d3b\u7528\u3057\u3066\u5909\u6570\u5024\u3092\u78ba\u8a8d<\/span><\/div>\n<div style=\"display:flex;align-items:flex-start;gap:8px;padding:6px 0;font-size:15px;line-height:1.6;\"><span style=\"color:#dc2626;font-size:16px;flex-shrink:0;margin-top:2px;\">&#10004;&#65039;<\/span><span><strong>\u30a8\u30e9\u30fc\u30ad\u30e3\u30c3\u30c1<\/strong> \u2192 On Error GoTo + Select Case 1004 + Err.Description\u306e\u30d1\u30bf\u30fc\u30f3<\/span><\/div>\n\n<\/div>\n\n\n\n<div class=\"g-flow-row\" style=\"margin:24px 0;\">\n  <div class=\"g-flow-item\"><strong>\u30a8\u30e9\u30fc1004<br>\u767a\u751f<\/strong><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u884c\u3092<br>\u7279\u5b9a\uff08\u9ec4\u8272\u30cf\u30a4\u30e9\u30a4\u30c8\uff09<\/strong><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>Debug.Print\u3067<br>\u5909\u6570\u5024\u3092\u78ba\u8a8d<\/strong><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>7\u30d1\u30bf\u30fc\u30f3\u304b\u3089<br>\u539f\u56e0\u3092\u7279\u5b9a<\/strong><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u30d1\u30bf\u30fc\u30f3\u5225\u306e<br>\u89e3\u6c7a\u30b3\u30fc\u30c9\u3092\u9069\u7528<\/strong><\/div>\n  <div class=\"g-flow-arrow\">&#8594;<\/div>\n  <div class=\"g-flow-item\"><strong>\u518d\u767a\u9632\u6b62\u306e<br>\u4e8b\u524d\u30c1\u30a7\u30c3\u30af\u3092\u8ffd\u52a0<\/strong><\/div>\n<\/div>\n\n\n\n<div class=\"balloon-wrap\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/ceo-sugasawa.jpg\" alt=\"\u4ee3\u8868\u83c5\u6fa4\">\n    <span class=\"balloon-name\">\u4ee3\u8868\u83c5\u6fa4<\/span>\n  <\/div>\n  <div class=\"balloon-body\">\u30a8\u30e9\u30fc1004\u306e\u6839\u672c\u7684\u306a\u89e3\u6c7a\u306f\u300c\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u304b\u3089\u76f4\u3059\u300d\u3067\u306f\u306a\u304f\u300c\u30a8\u30e9\u30fc\u304c\u51fa\u306a\u3044\u8a2d\u8a08\u306b\u3059\u308b\u300d\u3053\u3068\u3067\u3059\u3002Dir\u95a2\u6570\u3067\u306e\u30d5\u30a1\u30a4\u30eb\u78ba\u8a8d\u30fbSheetExists\u95a2\u6570\u3067\u306e\u30b7\u30fc\u30c8\u78ba\u8a8d\u30fbSelect\u3092\u4f7f\u308f\u306a\u3044\u76f4\u63a5\u4ee3\u5165\u2014\u2014\u3053\u308c\u3089\u3092\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306e\u7fd2\u6163\u306b\u3059\u308b\u3053\u3068\u3067\u3001\u30a8\u30e9\u30fc1004\u306e\u5927\u534a\u306f\u767a\u751f\u524d\u306b\u9632\u3052\u307e\u3059\u3002<\/div>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">VBA\u30a8\u30e9\u30fc1004\u306e\u89e3\u6c7a\u304b\u3089\u696d\u52d9\u30de\u30af\u30ed\u306e\u81ea\u52d5\u5316\u307e\u3067\u3001Claude Code\u3067\u5373\u5bfe\u5fdc<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u300c\u30a8\u30e9\u30fc1004\u304c\u51fa\u308b\u305f\u3073\u306b\u4f5c\u696d\u304c\u6b62\u307e\u3063\u3066\u3057\u307e\u3046\u300d\u300c\u696d\u52d9\u30de\u30af\u30ed\u3092\u4f5c\u308a\u305f\u3044\u304c\u30a8\u30e9\u30fc\u51e6\u7406\u306e\u8a2d\u8a08\u304c\u96e3\u3057\u3044\u300d\u300c\u73fe\u5834\u306eVBA\u30b3\u30fc\u30c9\u3092\u6574\u7406\u30fb\u6539\u5584\u3057\u305f\u3044\u300d\u2014\u2014\u5f0a\u793eAI\u9b3c\u7ba1\u7406\u3067\u306f\u3001Claude Code\u3092\u6d3b\u7528\u3057\u305f\u696d\u52d9VBA\u30de\u30af\u30ed\u306e\u8a2d\u8a08\u30fb\u5b9f\u88c5\u30fb\u30c7\u30d0\u30c3\u30b0\u652f\u63f4\u3092\u63d0\u4f9b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"balloon-wrap is-right\">\n  <div class=\"balloon-icon\">\n    <img decoding=\"async\" src=\"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-content\/uploads\/2026\/04\/yamazaki-avatar.png\" alt=\"AI\u9b3c\u7ba1\u7406\u5c71\u5d0e\">\n    <span class=\"balloon-name\">AI\u9b3c\u7ba1\u7406\u5c71\u5d0e<\/span>\n  <\/div>\n  <div class=\"balloon-body\">VBA\u30a8\u30e9\u30fc1004\u306f\u767a\u751f\u30d1\u30bf\u30fc\u30f3\u3055\u3048\u899a\u3048\u308c\u3070\u78ba\u5b9f\u306b\u89e3\u6c7a\u3067\u304d\u307e\u3059\u3002\u307e\u305a\u306f\u73fe\u5728\u767a\u751f\u3057\u3066\u3044\u308b\u30a8\u30e9\u30fc\u306e\u30b3\u30fc\u30c9\u3068\u72b6\u6cc1\u3092\u3054\u9023\u7d61\u304f\u3060\u3055\u3044\u3002\u6700\u77ed\u5f53\u65e5\u3067\u539f\u56e0\u7279\u5b9a\u3068\u89e3\u6c7a\u30b3\u30fc\u30c9\u3092\u3054\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/div>\n<\/div>\n\n\n\n<div style=\"background:linear-gradient(135deg,#1a1a1a 0%,#2a1015 100%);border-radius:16px;padding:36px 32px;margin:48px 0 16px;color:#fff;\">\n  <p style=\"font-size:13px;font-weight:700;color:#dc2626;letter-spacing:2px;margin:0 0 12px;\">NEXT STEP<\/p>\n  <p style=\"font-size:22px;font-weight:800;line-height:1.5;margin:0 0 20px;\">\u3053\u306e\u8a18\u4e8b\u306e\u5185\u5bb9\u3092\u3001\u3042\u306a\u305f\u306e\u30d3\u30b8\u30cd\u30b9\u3067<br>\u5b9f\u8df5\u3057\u3066\u307f\u307e\u305b\u3093\u304b\uff1f<\/p>\n  <div style=\"background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.12);border-radius:12px;padding:24px;max-width:560px;margin:0 auto;\">\n    <p style=\"font-size:13px;color:#dc2626;font-weight:700;margin:0 0 8px;\">AI\u6d3b\u7528\u3092\u81ea\u793e\u3067\u56de\u305b\u308b\u3088\u3046\u306b\u306a\u308a\u305f\u3044\u65b9\u3078<\/p>\n    <p style=\"font-size:20px;font-weight:800;margin:0 0 12px;\">AI\u9b3c\u7ba1\u7406<\/p>\n    <p style=\"font-size:14px;color:rgba(255,255,255,0.75);margin:0 0 20px;line-height:1.7;\">Claude Code\u30fbCowork\u5c0e\u5165\u652f\u63f4\u304b\u3089\u696d\u52d9\u8a2d\u8a08\u30fb\u793e\u5185\u6d78\u900f\u307e\u3067\u5b9f\u8df5\u30d9\u30fc\u30b9\u3067\u4f34\u8d70\u3002\u300c\u81ea\u793e\u3067\u56de\u305b\u308b\u7d44\u7e54\u300d\u309290\u65e5\u3067\u4f5c\u308b\u7d4c\u55b6\u8005\u5411\u3051\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u3002<\/p>\n    <div style=\"text-align:center;\">\n      <a href=\"https:\/\/aikanri.genai-ai.co.jp\/?utm_source=blog&utm_medium=article&utm_campaign=cc-vba-error-1004&utm_content=next-step-cta\" target=\"_blank\" rel=\"noopener\" style=\"display:inline-block;background:#dc2626;color:#fff;font-weight:700;font-size:15px;padding:14px 32px;border-radius:30px;text-decoration:none;\">AI\u9b3c\u7ba1\u7406\u3092\u8a73\u3057\u304f\u898b\u308b \u2192<\/a>\n    <\/div>\n  <\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"faq\">\u3088\u304f\u3042\u308b\u8cea\u554f<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Q. VBA\u30a8\u30e9\u30fc1004\u300cApplication-defined or object-defined error\u300d\u306f\u306a\u305c\u6c4e\u7528\u7684\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u306a\u306e\u3067\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. \u30a8\u30e9\u30fc1004\u306fExcel\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30e2\u30c7\u30eb\u304c\u300c\u64cd\u4f5c\u3092\u53d7\u3051\u4ed8\u3051\u3089\u308c\u306a\u3044\u300d\u5834\u5408\u306e\u7dcf\u79f0\u3068\u3057\u3066\u8a2d\u8a08\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3067\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u672a\u5b58\u5728\u30fb\u30b7\u30fc\u30c8\u672a\u5b58\u5728\u30fb\u4fdd\u8b77\u30b7\u30fc\u30c8\u3078\u306e\u66f8\u304d\u8fbc\u307f\u30fb\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306eSelect\u30fb\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u8d85\u904e\u306a\u3069\u3001\u591a\u69d8\u306a\u539f\u56e0\u304c\u540c\u3058\u756a\u53f7\u306b\u96c6\u7d04\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u89e3\u6c7a\u3059\u308b\u306b\u306f\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u884c\u3068\u3001\u305d\u306e\u6642\u70b9\u306e\u5909\u6570\u306e\u5024\u3092Debug.Print\u3067\u78ba\u8a8d\u3057\u3066\u30017\u3064\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u3069\u308c\u306b\u5f53\u3066\u306f\u307e\u308b\u304b\u3092\u7279\u5b9a\u3059\u308b\u3053\u3068\u304c\u6700\u3082\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q. \u30a8\u30e9\u30fc1004\u3068\u300c\u6dfb\u5b57\u304c\u7bc4\u56f2\u5916\uff08\u30a8\u30e9\u30fc9\uff09\u300d\u306e\u9055\u3044\u306f\u4f55\u3067\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. \u30a8\u30e9\u30fc9\uff08Subscript out of range\uff09\u306f\u4e3b\u306b\u300c\u5b58\u5728\u3057\u306a\u3044\u30b7\u30fc\u30c8\u540d\u30fb\u30d6\u30c3\u30af\u540d\u3067\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u6307\u5b9a\u3057\u305f\u300d\u3068\u304d\u306b\u767a\u751f\u3057\u307e\u3059\u3002\u4f8b\uff1aSheets(\"\u5b58\u5728\u3057\u306a\u3044\u540d\u524d\")\u3001Workbooks(5)\uff085\u500b\u3057\u304b\u30d6\u30c3\u30af\u304c\u958b\u3044\u3066\u3044\u306a\u3044\uff09\u3002\u30a8\u30e9\u30fc1004\u306f\u64cd\u4f5c\u81ea\u4f53\uff08\u66f8\u304d\u8fbc\u307f\u30fbSelect\u30fb\u30b3\u30d4\u30fc\uff09\u304c\u62d2\u5426\u3055\u308c\u308b\u5834\u5408\u306b\u767a\u751f\u3057\u307e\u3059\u3002Sheets(\"\u540d\u524d\")\u3067\u30b7\u30fc\u30c8\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u306f\u30a8\u30e9\u30fc9\u3001Select\/Activate\u3067\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u64cd\u4f5c\u306a\u3069\u306f\u30a8\u30e9\u30fc1004\u3067\u3059\u3002\u305f\u3060\u3057\u72b6\u6cc1\u306b\u3088\u3063\u3066\u91cd\u8907\u3059\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q. \u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306eSelect\u30a8\u30e9\u30fc\u3092\u6839\u672c\u7684\u306b\u306a\u304f\u3059\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u3088\u3044\u3067\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. Select\u3084Activate\u3092\u4f7f\u308f\u305a\u3001\u30b7\u30fc\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5909\u6570\uff08Dim ws As Worksheet \/ Set ws = Sheets(\"\u540d\u524d\")\uff09\u3092\u4f7f\u3063\u3066\u76f4\u63a5ws.Cells(1,1).Value\u3084Range.Value\u3092\u4ee3\u5165\u30fb\u53c2\u7167\u3059\u308b\u66f8\u304d\u65b9\u306b\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u6839\u672c\u89e3\u6c7a\u3067\u3059\u3002\u30de\u30af\u30ed\u8a18\u9332\u304c\u751f\u6210\u3057\u305fSelect\u591a\u7528\u306e\u30b3\u30fc\u30c9\u3092\u3001\u30b7\u30fc\u30c8\u5909\u6570\u306e\u76f4\u63a5\u64cd\u4f5c\u30d1\u30bf\u30fc\u30f3\u306b\u66f8\u304d\u63db\u3048\u308b\u3053\u3068\u3067\u3001\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306e\u30a8\u30e9\u30fc1004\u306f\u5b8c\u5168\u306b\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q. Dir\u95a2\u6570\u3068On Error Resume Next\u3092\u4f7f\u3063\u305f\u30d5\u30a1\u30a4\u30eb\u78ba\u8a8d\u306f\u3069\u3061\u3089\u304c\u63a8\u5968\u3067\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. \u30d5\u30a1\u30a4\u30eb\u306e\u5b58\u5728\u78ba\u8a8d\u306b\u306fDir\u95a2\u6570\u306e\u4f7f\u7528\u304c\u63a8\u5968\u3067\u3059\u3002Dir(filePath) <> \"\" \u3067\u30d5\u30a1\u30a4\u30eb\u306e\u6709\u7121\u3092\u78ba\u8a8d\u3057\u3066\u304b\u3089Workbooks.Open\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306f\u3001\u30a8\u30e9\u30fc\u3092\u300c\u767a\u751f\u524d\u306b\u9632\u3050\u300d\u8a2d\u8a08\u3067\u3059\u3002On Error Resume Next\u3092\u4f7f\u3046\u65b9\u6cd5\u3082\u52d5\u4f5c\u3057\u307e\u3059\u304c\u3001\u610f\u56f3\u3057\u306a\u3044\u30a8\u30e9\u30fc\u3092\u8aa4\u3063\u3066\u7121\u8996\u3059\u308b\u30ea\u30b9\u30af\u304c\u3042\u308a\u307e\u3059\u3002Dir\u95a2\u6570\u306f\u30b7\u30f3\u30d7\u30eb\u3067\u526f\u4f5c\u7528\u304c\u306a\u304f\u3001\u30d5\u30a1\u30a4\u30eb\u5b58\u5728\u78ba\u8a8d\u306e\u6a19\u6e96\u7684\u306a\u65b9\u6cd5\u3068\u3057\u3066\u5e83\u304f\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q. \u4fdd\u8b77\u30b7\u30fc\u30c8\u306bVBA\u3067\u66f8\u304d\u8fbc\u3080\u969b\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5b89\u5168\u306b\u7ba1\u7406\u3059\u308b\u306b\u306f\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. \u30b7\u30fc\u30c8\u4fdd\u8b77\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092VBA\u30b3\u30fc\u30c9\u306b\u76f4\u66f8\u304d\u3059\u308b\u3068\u3001VBA\u30a8\u30c7\u30a3\u30bf\u3092\u958b\u3051\u308b\u4eba\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\uff081\uff09VBA\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u81ea\u4f53\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u304b\u3051\u308b\u3001\uff082\uff09\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5225\u306e\u4fdd\u8b77\u3055\u308c\u305f\u30b7\u30fc\u30c8\u306e\u30bb\u30eb\u306b\u4fdd\u5b58\u3057\u3066VBA\u304b\u3089\u8aad\u307f\u8fbc\u3080\u3001\uff083\uff09InputBox\u3067\u30de\u30af\u30ed\u5b9f\u884c\u6642\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3055\u305b\u308b\u3001\u306e\u3044\u305a\u308c\u304b\u306e\u65b9\u6cd5\u3092\u53d6\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q. \u30a8\u30e9\u30fc1004\u306e\u30c7\u30d0\u30c3\u30b0\u3067\u6700\u521d\u306b\u78ba\u8a8d\u3059\u3079\u304d\u3053\u3068\u306f\u4f55\u3067\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. \u6700\u521d\u306b\u78ba\u8a8d\u3059\u3079\u304d\u306f\u300c\u3069\u306e\u884c\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u3044\u308b\u304b\u300d\u3067\u3059\u3002F5\u3067\u30de\u30af\u30ed\u3092\u5b9f\u884c\u3057\u3066\u30a8\u30e9\u30fc\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u51fa\u305f\u3068\u304d\u306b\u300c\u30c7\u30d0\u30c3\u30b0\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u884c\u304cVBA\u30a8\u30c7\u30a3\u30bf\u3067\u9ec4\u8272\u304f\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u307e\u3059\u3002\u6b21\u306b\u305d\u306e\u884c\u306e\u5909\u6570\u306e\u5024\u3092Debug.Print\u304b\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\uff08?\u5909\u6570\u540d\uff09\u3067\u78ba\u8a8d\u3057\u307e\u3059\u3002\u300c\u3069\u306e\u64cd\u4f5c\u3092\u3057\u3088\u3046\u3068\u3057\u3066\u300d\u300c\u5909\u6570\u304c\u3069\u3093\u306a\u5024\u3060\u3063\u305f\u304b\u300d\u304c\u5206\u304b\u308c\u3070\u3001\u3053\u306e\u8a18\u4e8b\u306e7\u3064\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u3069\u308c\u304b\u306b\u5f53\u3066\u306f\u3081\u3066\u89e3\u6c7a\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q. \u30a8\u30e9\u30fc1004\u3092\u5b8c\u5168\u306b\u306a\u304f\u3059\u305f\u3081\u306b\u65e5\u3054\u308d\u304b\u3089\u3067\u304d\u308b\u8a2d\u8a08\u4e0a\u306e\u5bfe\u7b56\u306f\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A. \u4ee5\u4e0b\u306e\u7fd2\u6163\u3067\u30a8\u30e9\u30fc1004\u306e\u767a\u751f\u3092\u5927\u5e45\u306b\u6e1b\u3089\u305b\u307e\u3059\u3002\uff081\uff09Workbooks.Open\u306e\u524d\u306bDir\u95a2\u6570\u3067\u30d5\u30a1\u30a4\u30eb\u78ba\u8a8d\u3092\u5165\u308c\u308b\u3002\uff082\uff09Sheets(\"\u540d\u524d\")\u3092\u4f7f\u3046\u524d\u306bSheetExists\u95a2\u6570\u3067\u78ba\u8a8d\u3059\u308b\u3002\uff083\uff09Select\/Activate\u3092\u4f7f\u308f\u305a\u30b7\u30fc\u30c8\u5909\u6570\u306e\u76f4\u63a5\u64cd\u4f5c\u306b\u7d71\u4e00\u3059\u308b\u3002\uff084\uff09\u30b3\u30d4\u30fc\uff06\u30da\u30fc\u30b9\u30c8\u306e\u4ee3\u308f\u308a\u306bRange.Value = Range.Value\u306e\u76f4\u63a5\u4ee3\u5165\u3092\u4f7f\u3046\u3002\uff085\uff09\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u8a08\u7b97\u3059\u308b\u5834\u5408\u306f1\u4ee5\u4e0a\u30fbRows.Count\/Columns.Count\u4ee5\u4e0b\u306e\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u308b\u3002\u3053\u308c\u3089\u3092\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u6a19\u6e96\u3068\u3057\u3066\u4f7f\u3046\u3053\u3068\u3067\u3001\u30a8\u30e9\u30fc1004\u306e\u5927\u534a\u306f\u4e8b\u524d\u306b\u9632\u3052\u307e\u3059\u3002<\/p>\n\n\n\n<script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [\n    {\n      \"@type\": \"Question\",\n      \"name\": \"VBA\u30a8\u30e9\u30fc1004\u300cApplication-defined or object-defined error\u300d\u306f\u306a\u305c\u6c4e\u7528\u7684\u306a\u30e1\u30c3\u30bb\u30fc\u30b8\u306a\u306e\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"\u30a8\u30e9\u30fc1004\u306fExcel\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30e2\u30c7\u30eb\u304c\u300c\u64cd\u4f5c\u3092\u53d7\u3051\u4ed8\u3051\u3089\u308c\u306a\u3044\u300d\u5834\u5408\u306e\u7dcf\u79f0\u3068\u3057\u3066\u8a2d\u8a08\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3067\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u672a\u5b58\u5728\u30fb\u30b7\u30fc\u30c8\u672a\u5b58\u5728\u30fb\u4fdd\u8b77\u30b7\u30fc\u30c8\u3078\u306e\u66f8\u304d\u8fbc\u307f\u30fb\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306eSelect\u30fb\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u8d85\u904e\u306a\u3069\u3001\u591a\u69d8\u306a\u539f\u56e0\u304c\u540c\u3058\u756a\u53f7\u306b\u96c6\u7d04\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u89e3\u6c7a\u3059\u308b\u306b\u306f\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u884c\u3068\u3001\u305d\u306e\u6642\u70b9\u306e\u5909\u6570\u306e\u5024\u3092Debug.Print\u3067\u78ba\u8a8d\u3057\u3066\u30017\u3064\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u3069\u308c\u306b\u5f53\u3066\u306f\u307e\u308b\u304b\u3092\u7279\u5b9a\u3059\u308b\u3053\u3068\u304c\u6700\u3082\u91cd\u8981\u3067\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"\u30a8\u30e9\u30fc1004\u3068\u300c\u6dfb\u5b57\u304c\u7bc4\u56f2\u5916\uff08\u30a8\u30e9\u30fc9\uff09\u300d\u306e\u9055\u3044\u306f\u4f55\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"\u30a8\u30e9\u30fc9\uff08Subscript out of range\uff09\u306f\u4e3b\u306b\u300c\u5b58\u5728\u3057\u306a\u3044\u30b7\u30fc\u30c8\u540d\u30fb\u30d6\u30c3\u30af\u540d\u3067\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u6307\u5b9a\u3057\u305f\u300d\u3068\u304d\u306b\u767a\u751f\u3057\u307e\u3059\u3002\u4f8b\uff1aSheets(\\\"\u5b58\u5728\u3057\u306a\u3044\u540d\u524d\\\")\u3001Workbooks(5)\uff085\u500b\u3057\u304b\u30d6\u30c3\u30af\u304c\u958b\u3044\u3066\u3044\u306a\u3044\uff09\u3002\u30a8\u30e9\u30fc1004\u306f\u64cd\u4f5c\u81ea\u4f53\uff08\u66f8\u304d\u8fbc\u307f\u30fbSelect\u30fb\u30b3\u30d4\u30fc\uff09\u304c\u62d2\u5426\u3055\u308c\u308b\u5834\u5408\u306b\u767a\u751f\u3057\u307e\u3059\u3002Sheets(\\\"\u540d\u524d\\\")\u3067\u30b7\u30fc\u30c8\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u306f\u30a8\u30e9\u30fc9\u3001Select\/Activate\u3067\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u64cd\u4f5c\u306a\u3069\u306f\u30a8\u30e9\u30fc1004\u3067\u3059\u3002\u305f\u3060\u3057\u72b6\u6cc1\u306b\u3088\u3063\u3066\u91cd\u8907\u3059\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306eSelect\u30a8\u30e9\u30fc\u3092\u6839\u672c\u7684\u306b\u306a\u304f\u3059\u306b\u306f\u3069\u3046\u3059\u308c\u3070\u3088\u3044\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"Select\u3084Activate\u3092\u4f7f\u308f\u305a\u3001\u30b7\u30fc\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u5909\u6570\uff08Dim ws As Worksheet \/ Set ws = Sheets(\\\"\u540d\u524d\\\")\uff09\u3092\u4f7f\u3063\u3066\u76f4\u63a5ws.Cells(1,1).Value\u3084Range.Value\u3092\u4ee3\u5165\u30fb\u53c2\u7167\u3059\u308b\u66f8\u304d\u65b9\u306b\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u6839\u672c\u89e3\u6c7a\u3067\u3059\u3002\u30de\u30af\u30ed\u8a18\u9332\u304c\u751f\u6210\u3057\u305fSelect\u591a\u7528\u306e\u30b3\u30fc\u30c9\u3092\u3001\u30b7\u30fc\u30c8\u5909\u6570\u306e\u76f4\u63a5\u64cd\u4f5c\u30d1\u30bf\u30fc\u30f3\u306b\u66f8\u304d\u63db\u3048\u308b\u3053\u3068\u3067\u3001\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u306e\u30a8\u30e9\u30fc1004\u306f\u5b8c\u5168\u306b\u306a\u304f\u306a\u308a\u307e\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Dir\u95a2\u6570\u3068On Error Resume Next\u3092\u4f7f\u3063\u305f\u30d5\u30a1\u30a4\u30eb\u78ba\u8a8d\u306f\u3069\u3061\u3089\u304c\u63a8\u5968\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"\u30d5\u30a1\u30a4\u30eb\u306e\u5b58\u5728\u78ba\u8a8d\u306b\u306fDir\u95a2\u6570\u306e\u4f7f\u7528\u304c\u63a8\u5968\u3067\u3059\u3002Dir(filePath) <> \\\"\\\" \u3067\u30d5\u30a1\u30a4\u30eb\u306e\u6709\u7121\u3092\u78ba\u8a8d\u3057\u3066\u304b\u3089Workbooks.Open\u3092\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u306f\u3001\u30a8\u30e9\u30fc\u3092\u300c\u767a\u751f\u524d\u306b\u9632\u3050\u300d\u8a2d\u8a08\u3067\u3059\u3002On Error Resume Next\u3092\u4f7f\u3046\u65b9\u6cd5\u3082\u52d5\u4f5c\u3057\u307e\u3059\u304c\u3001\u610f\u56f3\u3057\u306a\u3044\u30a8\u30e9\u30fc\u3092\u8aa4\u3063\u3066\u7121\u8996\u3059\u308b\u30ea\u30b9\u30af\u304c\u3042\u308a\u307e\u3059\u3002Dir\u95a2\u6570\u306f\u30b7\u30f3\u30d7\u30eb\u3067\u526f\u4f5c\u7528\u304c\u306a\u304f\u3001\u30d5\u30a1\u30a4\u30eb\u5b58\u5728\u78ba\u8a8d\u306e\u6a19\u6e96\u7684\u306a\u65b9\u6cd5\u3068\u3057\u3066\u5e83\u304f\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"\u4fdd\u8b77\u30b7\u30fc\u30c8\u306bVBA\u3067\u66f8\u304d\u8fbc\u3080\u969b\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5b89\u5168\u306b\u7ba1\u7406\u3059\u308b\u306b\u306f\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"\u30b7\u30fc\u30c8\u4fdd\u8b77\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u3092VBA\u30b3\u30fc\u30c9\u306b\u76f4\u66f8\u304d\u3059\u308b\u3068\u3001VBA\u30a8\u30c7\u30a3\u30bf\u3092\u958b\u3051\u308b\u4eba\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\uff081\uff09VBA\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u81ea\u4f53\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u304b\u3051\u308b\u3001\uff082\uff09\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5225\u306e\u4fdd\u8b77\u3055\u308c\u305f\u30b7\u30fc\u30c8\u306e\u30bb\u30eb\u306b\u4fdd\u5b58\u3057\u3066VBA\u304b\u3089\u8aad\u307f\u8fbc\u3080\u3001\uff083\uff09InputBox\u3067\u30de\u30af\u30ed\u5b9f\u884c\u6642\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3055\u305b\u308b\u3001\u306e\u3044\u305a\u308c\u304b\u306e\u65b9\u6cd5\u3092\u53d6\u3063\u3066\u304f\u3060\u3055\u3044\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"\u30a8\u30e9\u30fc1004\u306e\u30c7\u30d0\u30c3\u30b0\u3067\u6700\u521d\u306b\u78ba\u8a8d\u3059\u3079\u304d\u3053\u3068\u306f\u4f55\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"\u6700\u521d\u306b\u78ba\u8a8d\u3059\u3079\u304d\u306f\u300c\u3069\u306e\u884c\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u3044\u308b\u304b\u300d\u3067\u3059\u3002F5\u3067\u30de\u30af\u30ed\u3092\u5b9f\u884c\u3057\u3066\u30a8\u30e9\u30fc\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u51fa\u305f\u3068\u304d\u306b\u300c\u30c7\u30d0\u30c3\u30b0\u300d\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u884c\u304cVBA\u30a8\u30c7\u30a3\u30bf\u3067\u9ec4\u8272\u304f\u30cf\u30a4\u30e9\u30a4\u30c8\u3055\u308c\u307e\u3059\u3002\u6b21\u306b\u305d\u306e\u884c\u306e\u5909\u6570\u306e\u5024\u3092Debug.Print\u304b\u30a4\u30df\u30c7\u30a3\u30a8\u30a4\u30c8\u30a6\u30a3\u30f3\u30c9\u30a6\uff08?\u5909\u6570\u540d\uff09\u3067\u78ba\u8a8d\u3057\u307e\u3059\u3002\u300c\u3069\u306e\u64cd\u4f5c\u3092\u3057\u3088\u3046\u3068\u3057\u3066\u300d\u300c\u5909\u6570\u304c\u3069\u3093\u306a\u5024\u3060\u3063\u305f\u304b\u300d\u304c\u5206\u304b\u308c\u3070\u3001\u3053\u306e\u8a18\u4e8b\u306e7\u3064\u306e\u30d1\u30bf\u30fc\u30f3\u306e\u3069\u308c\u304b\u306b\u5f53\u3066\u306f\u3081\u3066\u89e3\u6c7a\u3067\u304d\u307e\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"\u30a8\u30e9\u30fc1004\u3092\u5b8c\u5168\u306b\u306a\u304f\u3059\u305f\u3081\u306b\u65e5\u3054\u308d\u304b\u3089\u3067\u304d\u308b\u8a2d\u8a08\u4e0a\u306e\u5bfe\u7b56\u306f\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"\u4ee5\u4e0b\u306e\u7fd2\u6163\u3067\u30a8\u30e9\u30fc1004\u306e\u767a\u751f\u3092\u5927\u5e45\u306b\u6e1b\u3089\u305b\u307e\u3059\u3002\uff081\uff09Workbooks.Open\u306e\u524d\u306bDir\u95a2\u6570\u3067\u30d5\u30a1\u30a4\u30eb\u78ba\u8a8d\u3092\u5165\u308c\u308b\u3002\uff082\uff09Sheets(\\\"\u540d\u524d\\\")\u3092\u4f7f\u3046\u524d\u306bSheetExists\u95a2\u6570\u3067\u78ba\u8a8d\u3059\u308b\u3002\uff083\uff09Select\/Activate\u3092\u4f7f\u308f\u305a\u30b7\u30fc\u30c8\u5909\u6570\u306e\u76f4\u63a5\u64cd\u4f5c\u306b\u7d71\u4e00\u3059\u308b\u3002\uff084\uff09\u30b3\u30d4\u30fc\uff06\u30da\u30fc\u30b9\u30c8\u306e\u4ee3\u308f\u308a\u306bRange.Value = Range.Value\u306e\u76f4\u63a5\u4ee3\u5165\u3092\u4f7f\u3046\u3002\uff085\uff09\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u8a08\u7b97\u3059\u308b\u5834\u5408\u306f1\u4ee5\u4e0a\u30fbRows.Count\/Columns.Count\u4ee5\u4e0b\u306e\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u308b\u3002\u3053\u308c\u3089\u3092\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u6a19\u6e96\u3068\u3057\u3066\u4f7f\u3046\u3053\u3068\u3067\u3001\u30a8\u30e9\u30fc1004\u306e\u5927\u534a\u306f\u4e8b\u524d\u306b\u9632\u3052\u307e\u3059\u3002\"\n      }\n    }\n  ]\n}\n<\/script>\n\n\n","protected":false},"excerpt":{"rendered":"<p>VBA\u5b9f\u884c\u6642\u30a8\u30e9\u30fc1004\uff08Application-defined or object-defined error\uff09\u306e\u5168\u539f\u56e0\u3068\u89e3\u6c7a\u65b9\u6cd5\u3092\u89e3\u8aac\u3002\u30d5\u30a1\u30a4\u30eb\u672a\u5b58\u5728\u30fb\u30b7\u30fc\u30c8\u672a\u5b58\u5728\u30fb\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u30fb\u30bb\u30eb\u7bc4\u56f2\u4e0d\u4e00\u81f4\u30fb\u30b3\u30d4\u30fc\u30da\u30fc\u30b9\u30c8\u30fb\u4fdd\u8b77\u30b7\u30fc\u30c8\u306a\u3069\u767a\u751f\u30d1\u30bf\u30fc\u30f3\u5225\u306e\u5bfe\u51e6\u6cd5\u3092\u30b3\u30fc\u30c9\u4f8b\u4ed8\u304d\u3067\u7db2\u7f85\u3002<\/p>\n","protected":false},"author":1,"featured_media":18377,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"sitemap_hide":"","_veu_custom_css":"","vkexunit_cta_each_option":"","footnotes":"","rank_math_description":"VBA\u5b9f\u884c\u6642\u30a8\u30e9\u30fc1004\uff08Application-defined or object-defined error\uff09\u306e\u5168\u539f\u56e0\u3068\u89e3\u6c7a\u65b9\u6cd5\u3092\u89e3\u8aac\u3002\u30d5\u30a1\u30a4\u30eb\u672a\u5b58\u5728\u30fb\u30b7\u30fc\u30c8\u672a\u5b58\u5728\u30fb\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u30b7\u30fc\u30c8\u30fb\u30bb\u30eb\u7bc4\u56f2\u4e0d\u4e00\u81f4\u30fb\u30b3\u30d4\u30fc\u30da\u30fc\u30b9\u30c8\u30fb\u4fdd\u8b77\u30b7\u30fc\u30c8\u306a\u3069\u767a\u751f\u30d1\u30bf\u30fc\u30f3\u5225\u306e\u5bfe\u51e6\u6cd5\u3092\u30b3\u30fc\u30c9\u4f8b\u4ed8\u304d\u3067\u7db2\u7f85\u3002","rank_math_focus_keyword":"VBA \u30a8\u30e9\u30fc 1004","rank_math_title":"\u30102026\u5e747\u6708\u6700\u65b0\u3011VBA\u5b9f\u884c\u6642\u30a8\u30e9\u30fc1004\u306e\u539f\u56e0\u3068\u89e3\u6c7a\u65b9\u6cd5\u5b8c\u5168\u30ac\u30a4\u30c9\uff5c\u767a\u751f\u30d1\u30bf\u30fc\u30f3\u5225\u306e\u5bfe\u51e6\u6cd5\u3092\u5b9f\u8df5\u30b3\u30fc\u30c9\u4ed8\u304d\u3067\u89e3\u8aac","pending_rewrite_html":"","pending_rewrite_id":"","pending_rewrite_kw":"","pending_rewrite_at":"","pending_rewrite_source":"","pending_rewrite_brief":"","pending_rewrite_evidence":"","approved_rewrite_html":"","approved_rewrite_id":"","approved_rewrite_kw":"","approved_rewrite_at":"","approved_rewrite_by":"","approved_rewrite_brief":"","approved_rewrite_evidence":"","rewrite_tracker_baseline":"","rewrite_tracker_7day":"","rewrite_tracker_14day":"","rewrite_tracker_30day":"","rewrite_tracker_notified":""},"categories":[3],"tags":[],"class_list":["post-18378","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai-automation"],"_links":{"self":[{"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/posts\/18378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/comments?post=18378"}],"version-history":[{"count":1,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/posts\/18378\/revisions"}],"predecessor-version":[{"id":18379,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/posts\/18378\/revisions\/18379"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/media\/18377"}],"wp:attachment":[{"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/media?parent=18378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/categories?post=18378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/genai-ai.co.jp\/ai-kanri\/wp-json\/wp\/v2\/tags?post=18378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}