Office
 Computer >> コンピューター >  >> ソフトウェア >> Office

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

IF ステートメントを使用する最も簡単な方法を探している場合 データ検証で Excelで式を作成する場合は、この記事が役立ちます。 データ検証 ドロップダウンリストを作成したり、範囲内の特定のデータのみを入力したりするのに役立ちます。
IF ステートメントの使用法について詳しく知るには データ検証で 式、メインの記事を始めましょう。

ワークブックをダウンロード

Excel のデータ検証式で IF ステートメントを使用する 6 つの方法

ここには、いくつかの製品とそれに対応する会社の営業担当者の名前の記録があります。このデータセットを使用して、 IF ステートメント の使用方法を示します。 データ検証

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Microsoft Excel 365 を使用しています 必要に応じて他のバージョンを使用できます。

方法-1 :IF ステートメントを使用して、データ検証式を利用して条件付きリストを作成する

条件付きリストを作成するために、ここでは従業員の氏名をヘッダー の下に配置しました 従業員の名前には、ヘッダー Full Name を使用しました . IF 関数の使用 データ検証 右側の表に条件付きリストを作成します.

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

歩数 :
➤ 範囲 E3:E12 を選択します 次に データ に移動します タブ>> データ ツール グループ>> データ検証 ドロップダウン>> データ検証 オプション。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

次に、 データ検証 ダイアログボックスが表示されます。
リストを選択します 許可 のオプション ボックスに入力し、 ソース に次の式を書き込みます ボックスを開き、OK をクリックします .

=IF($E$3=$B$3,$C$3:$C$12,$B$3:$B$12)

こちら $E$3 ドロップダウン リストからヘッダーを選択するセル $B$3 最初の列のヘッダー名です。これら 2 つの値が等しくなる場合 IF 範囲 $C$3:$C$12 のリストを返します 、それ以外の場合、リストには $B$3:$B$12 の範囲の値が含まれます .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

➤ セル E3 のドロップダウン シンボルをクリックすると、 、ヘッダー First Name を取得します

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

➤ セル E4 の名のリストから名を選択します .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

このようにして、ヘッダー First Name とともに営業担当者の名を取得しています。 .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

First Name からヘッダー名を変更できます フルネームに セル E3 内 .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

➤ リストから残りのセルの完全な名前を選択します。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

最後に、対応するヘッダーを持つ従業員の氏名を取得します。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

続きを読む: Excel で表からデータ検証リストを作成する方法 (3 つの方法)

方法-2 :データ検証式で IF ステートメントを使用して依存ドロップダウン リストを作成する

このセクションでは、Item が含まれる依存ドロップダウン リストを作成します。 リストは カテゴリ に依存します リスト。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

歩数 :
➤ セル E5 を選択します 、次に データ に移動します タブ>> データ ツール グループ>> データ検証 ドロップダウン>> データ検証 オプション。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

その後、 データ検証 ダイアログボックスが表示されます。
リストを選択します 許可 のオプション ボックスを開き、次の式を ソース に書き込みます。 ボックス

=$B$3:$C$3

こちら $B$3 ヘッダー フルーツ です そして $C$3 ヘッダー Vegetables です .

OK を押します .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

➤ セル E5 のドロップダウン記号をクリックした後 、リストにヘッダー名が表示されるので、 Fruits を選択しましょう このリストから。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

次に、セル F5 に項目リストを作成します .
リストを選択します 許可 のオプション ボックスを開き、次の式を ソース に書き込みます。 ボックス

=IF($E$5="Fruits",$B$4:$B$12,$C$4:$C$12)

セルの値 $E$5 「フルーツ」と同じになります 、 IF 範囲 $B$4:$B$12 を返します それ以外の場合、リストには範囲 $C$4:$C$12 が含まれます .

OK を押します .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

次に、Apple などのフルーツ アイテムを選択します。 、セルのドロップダウン リストをクリックします F5 リストからこのアイテムを選択します。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

その後、目的のアイテム Apple を取得します。 フルーツ カテゴリ .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

カテゴリを選択できます 野菜として これもリストから。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

次に、項目リストで野菜のリストを取得し、最初の野菜 (好きな方) を選択します キャベツ ここから。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

最後に、アイテム キャベツ を取得します 対応する カテゴリ 野菜 .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

続きを読む: Excel で複数選択可能なデータ検証ドロップダウン リストを作成する

方法-3 :Excel のデータ検証式で IF ステートメントと名前付き範囲を使用する

ここでは、名前付き範囲を IF 関数 と共に使用します。 データ検証 ドロップダウン リストを作成する式。
果物の範囲を Fruits と名付けました Vegetables としての野菜の範囲 .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

歩数 :
➤ セル E5 を選択します 、次に データ に移動します タブ>> データ ツール グループ>> データ検証 ドロップダウン>> データ検証 オプション。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

その後、 データ検証 ダイアログボックスが表示されます。
リストを選択します 許可 のオプション box, and write the following formula in the Source box

=$B$3:$C$3

Here, $B$3 is the header Fruits and $C$3 is the header Vegetables .

OK を押します .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

➤ Now, click on the dropdown symbol of cell E5 , you will get the header names on the list, and select Fruits from this list.

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Now, it’s time to make the items list in cell F5 .
➤ Select the List option in the Allow box, and write the following formula in the Source box

=IF($E$5="Fruits",Fruits,Vegetables)

When the value of the cell $E$5 will be equal to “Fruits” , IF will return the named range Fruits as a list otherwise the list will contain the named range Vegetables .

OK を押します .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

➤ Click on the dropdown list of cell F5 , and select the item Apple リストから。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Then, you will get your desired item Apple for the category Fruits .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

➤ Select the item Cabbage from the list for the category Vegetables .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Eventually, we are getting the Item Cabbage for the corresponding Category Vegetables .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

続きを読む: How to Use Named Range for Data Validation List with VBA in Excel

類似の読み方:

  • Excel データ検証 英数字のみ (カスタム数式を使用)
  • 配列からデータ検証リストを作成する Excel VBA
  • Excel Data Validation Based on Another Cell Value

方法-4 :Using the IF and INDIRECT Functions in Data Validation Formula in Excel

Here, we will be using the INDIRECT function along with the IF function to create a data validation 方式。 And we have the following named ranges Fruits and Vegetables for the fruits range and vegetables range respectively.

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Steps :
➤ Select the cell F5 , and then, go to the Data Tab>> Data Tools Group> > Data Validation Dropdown>> Data Validation オプション。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

After that, the Data Validation ダイアログボックスが表示されます。
➤ Select the List option in the Allow box, and write the following formula in the Source box

=IF($E$5="",Fruits,INDIRECT($E$5))

When the value of the cell $E$5 will be equal to Blank , IF will return the named range Fruits as a list otherwise INDIRECT($E$5) will check the value in the cell $E$5 and then link the value as a reference to the corresponding named range.

OK を押します .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

➤ Here, we have a blank in cell E5 , and for this blank, we are having the list of fruits in the dropdown list of cell F5 , and then select the first one Apple リストから。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

For the blank as a Category , we are having the Item as a fruit Apple .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Now, you can write down the Category as Vegetables , and then you will get the list of vegetables in cell F5 .|
➤ Select Cabbage from the vegetable list of the Item

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Eventually, we are getting the Item Cabbage for the corresponding Category Vegetables .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

続きを読む: How to Create Excel Drop Down List for Data Validation (8 Ways)

方法-5 :Using Nested IF Functions in Data Validation Formula

Here, we are going to use nested IF functions for multiple conditions in a Data Validation formula to create a dropdown list for the Fruits , Vegetables , and Fruits .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Steps :
➤ Select the cell E5 , and then, go to the Data Tab>> Data Tools Group> > Data Validation Dropdown>> Data Validation オプション。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Then, the Data Validation ダイアログボックスが表示されます。
➤ Select the List option in the Allow box, and write the following formula in the Source box

=$B$3:$C$3

Here, $B$3 is the header Fruits and $C$3 is the header Vegetables .

OK を押します .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

➤ Now, click on the dropdown symbol of cell E5 , you will get the header names on the list, and select Fruits from this list.

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

We will make the items list in cell F5 今。
➤ Select the List option in the Allow box and write the following formula in the Source box

=IF($E$5="Fruits",$B$4:$B$12,IF($E$5="Vegetables",$C$4:$C$12,$D$4:$D$12))

When the value of the cell $E$5 will be equal to “Fruits” , IF will return the range $B$4:$B$12 as a list, otherwise it will go to the next IF function which will check for the value “Vegetables” .
If the condition of this function is fulfilled, then it will return the range $C$4:$C$12 as a list otherwise $D$4:$D$12 will be used in the list.

OK を押します .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

➤ Click on the dropdown list of cell F5 , and select the item Apple リストから。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Then, you will get your desired item Apple for the category Fruits .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

➤ Select the item Cabbage from the list for the category Vegetables .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Then, you will have the Item Cabbage for the Category Vegetables .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

For selecting the Category as Fish you will have the list of the fishes in cell F5 of the Item 桁。
➤ Select the first Item Salmon from the list or any other item.

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Eventually, we are getting the Item Salmon for the Category Fish after selecting from the list.

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

関連コンテンツ: Apply Custom Data Validation for Multiple Criteria in Excel (4 Examples)

Method-6 :Using IF Statement in Data Validation Formula for Dates

Here, we will try to restrict the entries for the dates of the Delivery Date column in a way that the cells of this column will only accept the dates previous to today’s date (3/21/2022 as m/dd/yyyy format), and for entering dates greater than today’s date we will get an error message. For this purpose, we will be using the TODAY function along with the IF function .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Steps :
➤ Select the range E4:E12 , and then, go to the Data Tab>> Data Tools Group> > Data Validation Dropdown>> Data Validation オプション。

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Then, the Data Validation ダイアログボックスが表示されます。
➤ Select the Custom option in the Allow box, and write the following formula in the Source box

=IF($D$4:$D$12="*",$E$4:$E$12<=TODAY(),$E$4:$E$12="")

If the cells of the range $D$4:$D$12 contains any text string then the cells of the range $E$4:$E$12 will only allow the dates smaller than today’s date or 3/21/2022 .

OK を押します .

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

We can enter any dates without any problem except for the dates greater than today’s date as we can see from the following figure.

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

But when we try to enter a date 3/28/2022 which is not either less than or equal to today’s date,

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

we are having the following error message due to the data validation formula we had set previously.

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

So, we have filled the cells of the Delivery Date column with dates less than today’s date.

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

Related Content:How to Use Data Validation in Excel with Color (4 Ways)

練習セクション

For doing practice by yourself we have provided a Practice section like below in a sheet named Practice . Please do it by yourself.

Excel のデータ検証式で IF ステートメントを使用する方法 (6 つの方法)

結論

In this article, we tried to cover the ways to use the IF statement in a Data Validation formula in Excel easily. Hope you will find it useful. If you have any suggestions or questions, feel free to share them in the comment section.

関連記事

  • Excel Data Validation Drop Down List with Filter (2 Methods)
  • How to Apply Multiple Data Validation in One Cell in Excel (3 Examples)
  • Default Value in Data Validation List with Excel VBA (Macro and UserForm)
  • [修正] Excel でのコピー貼り付けでデータ検証が機能しない (ソリューションあり)
  • Excel データ検証でカスタム VLOOKUP 数式を使用する方法

  1. Excel で数式をトレースする方法 (3 つの効果的な方法)

    この記事では、Excel で数式をトレースする方法について説明します。エラーを修正したり、参照が正しいことを確認したりするには、式の監査が必要です。これを行うには、Excel で数式をトレースできます。 Precedents と Dependents は、Excel のトレース式に直接リンクされている 2 つの用語です。参照元は、数式で参照として使用されるセルです。一方、従属は、値が数式の出力に依存するセルです。 Excel の任意の数式またはセルに矢印で示された先例と依存関係を確認できます。その方法については、以下の方法に従ってください。 下のダウンロードボタンから練習用ワークブックをダ

  2. 特定の値を超えないように Excel 数式を使用する方法

    このチュートリアルでは、Excel の数式を使用して特定の値を超えないようにする方法を示します。大量のデータを扱う場合、データが超えないように一定の範囲を設定することが非常に必要になることがあります。企業や教育機関は、卓越性レベルや利益率を測定するために、この種の基準を設定しています。この記事では、データ検証などのさまざまな数式を使用します ,最大 、MIN 、RANDBETWEEN 、および IF 関数を使用して、超えてはならない値を設定します。 ここから練習用ワークブックをダウンロードできます。 特定の値を超えないように Excel の数式を使用する 6 つの簡単な方法 簡単に理解で