简体   繁体   中英

IF LOOP in VBA Function

I made two excel sheet. one contains information as below

Date            Name            Quantity
12/7/2013   Bharat Sapte        12
12/7/2013   Ghorpade            10
14/7/2013   Desmukh             30
17/7/2013   Ghorpade            35

and for second sheet

Name         Date            Date
             12/07/2013
Ghorpade     _**_            _**__

here in ** marked area it should check the condition with first sheet and automatically fill up the Quantity in second sheet

how to make this program for too many entries.

As said in the comments to your question, a Pivot table could do the job. A somewhat more static approach is to

  1. create a "key column" as a string concatenation of date & name before the Quantity column (can be hidden)
  2. use a =VLOOKUP(...) function to retrieve the quantity whereby the search argument is constructed from dates (column headers) and names (row headers) of the result table

截屏

The formulas in B9 and B10 are

  • B9: =VLOOKUP(B$8&$A9;$C$2:$D$5;2;FALSE)
  • B10: =VLOOKUP(C$8&$A9;$C$2:$D$5;2;FALSE)

Mind the usage of $ to make rows (date) and columns (name) absolute to make copying easy; and replace my ";" by "," in the formulas if you use the English locale.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM