<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>setValue</title>
	<atom:link href="https://office-automation-lab.com/tag/setvalue/feed/" rel="self" type="application/rss+xml" />
	<link>https://office-automation-lab.com</link>
	<description>AIとExcelで仕事を少しだけ楽にする方法を、リアルな体験と検証で発信</description>
	<lastBuildDate>Sun, 14 Jun 2026 13:46:57 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://office-automation-lab.com/wp-content/uploads/2026/06/cropped-サイト画像-32x32.jpg</url>
	<title>setValue</title>
	<link>https://office-automation-lab.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>GASで案件入力フォームのデータをクリアするコード（clearContent）｜入力フォーム初期化を自動化する方法</title>
		<link>https://office-automation-lab.com/gas-clear-project-entry-form/</link>
					<comments>https://office-automation-lab.com/gas-clear-project-entry-form/#respond</comments>
		
		<dc:creator><![CDATA[mkhome_ai]]></dc:creator>
		<pubDate>Sun, 14 Jun 2026 13:46:01 +0000</pubDate>
				<category><![CDATA[GASコード集]]></category>
		<category><![CDATA[clearContent]]></category>
		<category><![CDATA[GAS]]></category>
		<category><![CDATA[Google Apps Script]]></category>
		<category><![CDATA[setValue]]></category>
		<category><![CDATA[フォームクリア]]></category>
		<category><![CDATA[入力フォーム]]></category>
		<category><![CDATA[案件登録]]></category>
		<category><![CDATA[案件管理]]></category>
		<category><![CDATA[業務効率化]]></category>
		<guid isPermaLink="false">https://office-automation-lab.com/?p=618</guid>

					<description><![CDATA[・案件登録後に入力フォームを自動で空欄にできる・次の案件入力をすぐ開始できる・GAS初心者でもコピペで利用可能 このコードでできること ・案件データをデータベースへ登録 ・案件IDを自動採番 ・登録後に入力フォームを自動 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">・案件登録後に入力フォームを自動で空欄にできる<br>・次の案件入力をすぐ開始できる<br>・GAS初心者でもコピペで利用可能</p>



<h2 class="wp-block-heading">このコードでできること</h2>



<p class="wp-block-paragraph">・案件データをデータベースへ登録</p>



<p class="wp-block-paragraph">・案件IDを自動採番</p>



<p class="wp-block-paragraph">・登録後に入力フォームを自動クリア</p>



<h3 class="wp-block-heading">GASコード</h3>



<pre class="wp-block-code"><code>function saveProject() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var wsForm = ss.getSheetByName("案件入力フォーム");
  var wsDB = ss.getSheetByName("案件データベース");

  // 最終行取得
  var lastRow = wsDB.getLastRow();
  var nextRow = lastRow + 1;

  // 案件ID生成（A00001形式）
  var seq = nextRow - 1;
  var caseId = "A" + ("00000" + seq).slice(-5);

  // データ転記
  var date = new Date();
  var formattedDate = Utilities.formatDate(
    date,
    Session.getScriptTimeZone(),
    "yyyy/MM/dd"
  );

  wsDB.getRange(nextRow, 1).setValue(formattedDate);
  wsDB.getRange(nextRow, 2).setValue(caseId);
  wsDB.getRange(nextRow, 3).setValue(wsForm.getRange("C2").getValue());
  wsDB.getRange(nextRow, 4).setValue(wsForm.getRange("C3").getValue());
  wsDB.getRange(nextRow, 5).setValue(wsForm.getRange("C4").getValue());

  var dateValueC5 = wsForm.getRange("C5").getValue();
  wsDB.getRange(nextRow, 6).setValue(
    Utilities.formatDate(
      new Date(dateValueC5),
      Session.getScriptTimeZone(),
      "yyyy/MM/dd"
    )
  );

  wsDB.getRange(nextRow, 7).setValue(wsForm.getRange("C6").getValue());
  wsDB.getRange(nextRow, 8).setValue(wsForm.getRange("C7").getValue());
  wsDB.getRange(nextRow, 9).setValue(wsForm.getRange("C8").getValue());

  // 入力フォームのクリア
  wsForm.getRange("C2:C8").clearContent();

  // 完了通知
  SpreadsheetApp.getUi().alert("案件を登録しました。");
}
</code></pre>



<h2 class="wp-block-heading">カスタマイズ例</h2>



<h3 class="wp-block-heading">パターン①</h3>



<p class="wp-block-paragraph">入力項目を追加する場合</p>



<pre class="wp-block-code"><code>wsDB.getRange(nextRow, 10).setValue(
  wsForm.getRange("C9").getValue()
);
</code></pre>



<h3 class="wp-block-heading">パターン②</h3>



<p class="wp-block-paragraph">クリア範囲を広げる場合</p>



<pre class="wp-block-code"><code>wsForm.getRange("C2:C20").clearContent();
</code></pre>



<h2 class="wp-block-heading">よくあるエラー</h2>



<h3 class="wp-block-heading">症状</h3>



<p class="wp-block-paragraph">TypeError: Cannot read properties of null</p>



<p class="wp-block-paragraph">対処法<br>・シート名が一致しているか確認する<br>・案件入力フォーム、案件データベースの名称を確認する</p>



<h3 class="wp-block-heading">症状</h3>



<p class="wp-block-paragraph">入力フォームがクリアされない</p>



<p class="wp-block-paragraph">対処法<br>・clearContent()の記述位置を確認する<br>・C2:C8に入力データが存在するか確認する</p>



<h2 class="wp-block-heading">サンプルファイル</h2>



<p class="wp-block-paragraph">このコードを試せるGoogleスプレッドシートを配布しています。</p>



<p class="wp-block-paragraph">▶ <a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/10YwV5ia5-csZEv8kngEYsothQe7qm1vv7E9Ts845luw/edit?usp=sharing" data-type="link" data-id="https://docs.google.com/spreadsheets/d/10YwV5ia5-csZEv8kngEYsothQe7qm1vv7E9Ts845luw/edit?usp=sharing">案件入力フォーム_スプレッドシート（GASコードなし）</a></p>



<p class="wp-block-paragraph">▶ <a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/1tySRUA6uIT9dN7GFWniDDC3YzSyf8foMeF5EEj_OllE/edit?usp=sharing" data-type="link" data-id="https://docs.google.com/spreadsheets/d/1tySRUA6uIT9dN7GFWniDDC3YzSyf8foMeF5EEj_OllE/edit?usp=sharing">【完成】案件入力フォーム_スプレッドシート（GASコードあり）</a></p>



<h2 class="wp-block-heading">関連記事</h2>



<p class="wp-block-paragraph">▶ <a target="_blank" href="https://office-automation-lab.com/vba-project-registration/" data-type="link" data-id="https://office-automation-lab.com/vba-project-registration/">GASで案件データを登録するコード（setValue）</a></p>



<p class="wp-block-paragraph">▶ <a target="_blank" href="https://office-automation-lab.com/gas-function-name/" data-type="link" data-id="https://office-automation-lab.com/gas-function-name/">GASのマクロ名を確認する方法｜function ○○()がマクロ名です</a></p>



<p class="wp-block-paragraph">▶<a target="_blank" href="https://office-automation-lab.com/gas-daily-trigger/" data-type="link" data-id="https://office-automation-lab.com/gas-daily-trigger/"> GASで毎日自動実行する方法｜トリガー設定</a></p>



<h2 class="wp-block-heading">次回予告</h2>



<p class="wp-block-paragraph">次回は「GASでチェックボックスにチェックしたら別シートへ転記するコード」を紹介予定です。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://office-automation-lab.com/gas-clear-project-entry-form/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
