So i have a sheet called "Definições" that has a table "Tabela1" with 3 columns "Norma","Tipo" and "Tempo" and i was trying to make a search for specific words on all 3 and if match them return the value of the third one. However when making the search for only 2 columns i am having a hard time cause it's returning a
"Type mismatch" error type.
when setting the cell1 variable. So for the first column i am searching for "Carregamento para" and for the second one i am looking for "Pó Quimico B/C"
Dim ws As Worksheet
Set ws = Worksheets("Definições")
Dim tbl1 As ListObject
Set tbl1 = ws.ListObjects("Tabela1")
Dim cell1 As Range
Dim cell2 As Range
Dim r As Integer
r = 1
With tbl1
Do
Set cell1 = .ListColumns("Norma").DataBodyRange.Find(What:="Carregamento para", After:=tbl.DataBodyRange.Cells(r, 1))
Debug.Print "cell1="& cell1.Row & " r="& r
Set cell2 = .ListColumns("Tipo").DataBodyRange.Find(What:="Pó Químico B/C", After:=tbl.DataBodyRange.Cells(cell1.Row - 1, 2))
Debug.Print "cell2="& cell2.Row & " r="& r
r = cell2.Row - 1
MsgBox "Found "& cell1.Value & " at row "& cell1.Row & vbNewLine _
& "Found "& cell2.Value & " at row "& cell2.Row
Loop While cell1.Row = cell2.Row
MsgBox "Final value goes to row "& cell2.Row
End With
Just point me on the right direction and why this error is occurring since I know that using a type RANGE is the correct variable set for the find and maybe to know if this is in fact the right choice of code type to use for this situation.