I am trying to translate an index match formula into VBA code. I would like to do this because the cells that contain the index match formulas will not always have the same row values, so I can't simply place the formulas in specific rows. The formula is currently in column H, so I am trying to have VBA code that will match the values from the other sheet, and populate column H in the correct row based on the index match criteria.
Here is my formula:
=IFERROR(INDEX(Comments!$K$2:$K$76,MATCH(C8,Comments!$B$2:$B$76,0)),"COMMENT REQUIRED")
I initially tried adapting to be a V-Lookup in VBA code as I was told this would be easier, but I have not been able to do this successfully. The VBA code that I tried is below:
Dim h
With DestinationSheet.Rows(DestinationRow)
h = Application.VLookup(.Cells(3).Value, Sheets("Comments").Range("$A$2:$C$100"), 3, False)
.Cells(8).Value = IIf(IsError(h), "COMMENT REQUIRED", h)
.Cells(8).Font.Color = IIf(IsError(h), RGB(255, 0, 0), h)
.Cells(8).Font.Bold = IIf(IsError(h), True, h)
End With