Hello,

I found VBA code online that seems to be written to look up on 2 or more conditions.
I need help modifying it to fit my UserForm that takes data from a table on "Raw Data" tab and inserts it into a different table on "All" tab.

In the UserForm Column 3 will be entered into TextBox4 and Column 4 into TextBox5.
Criteria: Look up Column 3 (from TextBox4) and Column 4 (TextBox5)
If Column 4 is 0 then display Column 5 in TextBox13 and display Column 6 in TextBox14
If Column 4 is greater than 0 then display Column 7 in TextBox13

The code that I found online and needs to be modified:
Function ThreeParameterVlookup(Data_Range As Range, Col As Integer, Parameter1 As Variant, Parameter2 As Variant, Parameter3 As Variant) As Variant

'Declare Variables

Dim Cell
Dim Current_Row As Integer
Dim No_Of_Rows_in_Range As Integer
Dim No_of_Cols_in_Range As Integer
Dim Matching_Row As Integer


'set answer to N/A by default
ThreeParameterVlookup = CVErr(xlErrNA)
Matching_Row = 0
Current_Row = 1



No_Of_Rows_in_Range = Data_Range.Rows.Count
No_of_Cols_in_Range = Data_Range.Columns.Count
       
'Check if Col is greater than number of columns in range
'
       
If (Col > No_of_Cols_in_Range) Then
    ThreeParameterVlookup = CVErr(xlErrRef)
End If

If (Col <= No_of_Cols_in_Range) Then


    Do

    If ((Data_Range.Cells(Current_Row, 1).Value = Parameter1) And _
        (Data_Range.Cells(Current_Row, 2).Value = Parameter2) And _
        (Data_Range.Cells(Current_Row, 3).Value = Parameter3)) Then
        Matching_Row = Current_Row
      
    End If
    
    
    Current_Row = Current_Row + 1

    Loop Until ((Current_Row = No_Of_Rows_in_Range) Or (Matching_Row <> 0))

    If Matching_Row <> 0 Then
        ThreeParameterVlookup = Data_Range.Cells(Matching_Row, Col)
    End If

End If

End Function
If new code is esier to write, then you can ignore what i found.
Thanks!