简体   繁体   中英

Excel Macro find and copy corresponding cell apply formula on the value

Hi I am new to VBA script. I have the following problem.

Sheet 1

Date    Sum of cnt

01-04-2014  77 
01-06-2014  3 
01-07-2014  2 
01-08-2014  1
01-09-2014  921

Sheet 2

Date       count  (count/sumofcout(sheet1)

01-06-2014  3
01-09-2014  4
01-09-2014  712
01-07-2014   1
01-08-2014   1
01-09-2014  205 .....

I have to search for the every single date from sheet 1 if there is match in sheet 2 , corresponding count(sheet2)/sum0fcount of that date(sheet1) should be my third column in sheet 2. Please anyone help me. I have large data multiple values of each day in a month.

Thanks in advance.

As Tim has suggested in his comment above...you can use Vlookup/Match (along with SumIF) to get your results. A formula like this (with different ranges) should do the job:

IF( ISNA(MATCH(A2,Sheet1! $A$2:$A$13 ,0)),"",B2/SUMIF(Sheet1!$ A$2:$A$13 ,A2,Sheet1! $B$2:$B$13 ))

You can change the Ranges A2:A13, B2:B13 to adjust this according to your data

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