I currently have a With statement that will compare the value of a cell to a range of cells and InStr() returns true then mark cell.Value as "Yes" and if not then "No".
Here is the scenario. Say I am checking the value of A2 and this is 111. I am comparing 111 to a range of other cells and the field that should match is 111, 222, 333 as it contains 111 in it. My first set of code below works for this but is slow. I was hoping for a faster way and I think I can do this with a formula but using True instead of False in the vlookup is not working as I thought it would.
Here is the code:
With inv_twcg_ws
For Each cell In .Range("A2:A" & .Cells(Rows.Count, "A").End(xlUp).Row)
For Each cellx In report_rng
If InStr(cellx.Value, cell.Value) Then
cell.Offset(0, 6).Value = "Yes"
Exit For
End If
cell.Offset(0, 6).Value = "No"
Next cellx
Next cell
End With
The problem is it is kinda slow. My application takes about 5 min to run. I was hoping to combine InStr() with Application.Vlookup() somehow to try and speed up the formula. Is this possible?
Here is my current Vlookup but using True does not seam to be working for my needs...
With inv_twcg_ws
For Each cell In .Range("G2:G" & .Cells(Rows.Count, "A").End(xlUp).Row)
cell.Value = Application.WorksheetFunction.IfError(Application.VLookup(CStr(cell.Value), report_rng, 1, True), "No")
Next cell
End With