In general, the essence is this - you need to make a kind of query in Excel from an existing database (Sheet 1) into a decorated sheet for printing (Sheet 2, aka the “Price list for a client” form, so to speak). It is necessary that such a condition be checked whether the product name matches the typed one (let's say this is column A in both Sheets), and according to the name correspondence in column B the price of this product is indicated. In 1 sheet of the database with the name of the goods in column A, the price in column B. It is necessary to display the price of the entered goods in Sheet 2.
- If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky ♦
2 answers
This is easily done using the CDF function.
Here is the dialog box for this function:
How to use the CDF function.
=ВПР(B2;C2:E7,3,ИСТИНА) The first argument (the part of the data that provides the function) is the desired value. This may be a reference to a cell or a specific value, for example, “Yellow pencil” or “Laser printer”. The second argument is a range of cells, which, in your opinion, contains the desired value. In our example, this is the C2 – C7 range. The third argument is a column in the range of cells that contains the value to be found.
The fourth argument is optional. You can enter TRUE or FALSE. If you enter TRUE or leave the argument empty, the function returns an approximate match of the value specified as the first argument. If you enter FALSE, the function will match the value specified as the first argument. In other words, to provide additional flexibility, leave the fourth argument empty or enter the value TRUE.
This example shows how the function works. If you enter a value in cell B2 (first argument), the CDF function searches in cells C2 – E7 (second argument) and returns the most accurate approximate match from the third column in the range — column E (third argument).
The fourth argument is empty, so the function returns an approximate match. Otherwise, you will need to enter one of the values in column C or D to get any result.
For details, see the Quick Reference: VLR function.
And also - Search for values using the functions of the CDF
To solve the task, link the name of the Goods on Листе 2 with the Ценой on Листе 1 , use the MS Excel function ВПР() .
- Create
Лист 1(Product Database) with a list of products (Товарcolumn) and price (Ценаcolumn). We fill the cells with the values of Products and Prices.
Mandatory and necessary conditions for the correct operation of the ВПР() function ВПР() are: the Товар column is the first in the list and the values are sorted in alphabetical order.
Restrictions: correctly the ВПР() function ВПР() will not work for the same goods with different prices. For example:
Tea 122.00;
Tea 170.00.
- Create a
Лист 2(Pry-list) with columnsТоварandЦена.
- We associate the value of the imported goods with the prices placed on
Листе 1using theВПР()functionВПР()through the name of the goods.
The ВПР() function is called as follows:
the first argument is the
Искомое_значениеthat we are looking for inЛисте 1. In our case,А4;the second argument is the
Таблица, where we search, on which sheet and in what range. In our case,Лист1!$A$2:$B$9. Pay attention to the absolute links when setting the range$A$2:$B$9to avoid changing the search range when copying cells with formulas;the third argument is the column_number, the column number from which the value will be returned in case of a desired search value. In our case
2. If a value is found, then the value of the cell of the 2nd column will be returned, if not, then the value is#Н/Д;the fourth argument is Interval_View, a logical value that determines the accuracy of the search by the desired_value.
ЛОЖЬ- exact match,ИСТИНА- approximate.
- On
Листе 2replicate the cell with theВПР()formulaВПР()in theЦенаcolumn below. When you enter a value in theТоварcolumn, if the name matches the product value onЛисте 1, theВПР()functionВПР()returns the price value from theЦенаcolumn or#Н/Дvalue.
The result is a minimum achieved.
- To hide the
#Н/Дvalue in the absence of goods that have yet been entered and display a notification about the absence of goods onЛисте 1supplement theВПР()functionВПР()following conditions and functions:ЕСЛИ(),ЕНД(),ЕПУСТО(). The final edition of the function:=ЕСЛИ(ЕПУСТО(A4);"";ЕСЛИ(ЕНД(ВПР(A4;Лист1!$A$2:$B$9;2;ЛОЖЬ));"Нет продукта в списке цен";ВПР(A4;Лист1!$A$2:$B$9;2;ЛОЖЬ)))
- = IF (A4 = ""; ""; IFOR ERROR (CDF (A4; Sheet1! $ A $ 2: $ B $ 9; 2;); "No product in price list")) - formula for versions after Excel 2003 - vikttur





