Our programmer in our company had just resigned and my supervisor had asked me to help him by creating a formula or VB script which I have no knowledge in doing. I appreciate anyone who can provide me a solution.

In the Main worksheet in the Main Workbook (on attachment) I will need either a VB Macro or a formula that could achieve my task, please view steps below.

1. In each row containing the greatest number in the Sumof Quantity column (Column H) for each Primary in the prim_sec column (Column I, cells highlighted in pink), I will need a formula or VB Macro that will be able to copy data (cell highlighted in blue in the Example 1 worksheet) in the S Function column (Column F) and paste data in the cells below in the S Function column (view cells highlighted in green color ) that has a Secondary value located in the prim_sec column (Column I, view purple color). This needs to be done for each seperate person code located in the EID Column (Column B) for each separate date in the date column (Column A). FYI - In my Excel file back at work, I have about 50,000 records in my Workbook. The cells in my workbook back at my work is not color coded.

Note: I will need the VB or Macro in the Main worksheet. List is sorted by EID, Date, and prim_sec columns. I really appreciate the assistance. FYI - I am able to use Excel 2003, 2007, and 2010