In my workbook I have 2 worksheets: Sheet1 and Sheet2.
In Sheet1 I have the following data set:
In Sheet2 I have the following data set:
I need to create a code that will do the following:
- Populate the score columns ("Score of SpeGro", "Score of PrimSpe", etc.)
For example, for the "Score of SpeGro" column it needs to:
- Search in Sheet1 the column header corresponding to SpeGro (in this case it's column 4);
- The values of column 4 need to match the values in column 3 of Sheet2.
- Only consider the values in Sheet2 with the DIMENSION "SpeGro" (in this case);
- Only consider the values with PrdInd (Sheet1) = PrdInd (Sheet2).
Extra info: I have a INDEX-MATCH formula that works if I only had DIMENSION:
For k = 2 To RowNum
tWb.Sheets("Sheet1").Cells(k, 6).Value = Application.IfError(Application.Index(tWb.Sheets("Sheet2").Range("D:D"), Application.Match(tWb.Sheets("Sheet1").Cells(k, 4), tWb.Sheets("Sheet2").Range("C:C"), 0)), 0)
Next k