srivardhan kandike
srivardhan kandike

Reputation: 11

VBA Code to Check one Column Data with Multiple Columns Data?

I have id numbers on column A starts from A3 To A25. I want to check each of the column A value with the F G H I columns values. In F G H I columns where data starts from 29th-row, how do check with A column value with multiple columns values at a time?

lastrow = Range("A" & Rows.Count).End(xlUp).Row

lastrow1 = Range("F" & Rows.Count).End(xlUp).Row   
    
For i = 3 To lastrow
 
    For j = 30 To lastrow1
 
        If Range("F" & j).Value = Range("A" & i).Value Or Range("G" & j).Value = Range("A" & i).Value Or Range("H" & j).Value = Range("A" & i).Value Or Range("I" & j).Value = Range("A" & i).Value Then
        End if

    Next j

Next i

Upvotes: 1

Views: 1029

Answers (1)

Shyam Pandey
Shyam Pandey

Reputation: 62

use below code. i have tested on your query

Please test it if any problem, feel free to contact.

Function allvlookup(rng As Range, rng1 As Range)

    Dim rng_r As Range
    Dim str As String


    For Each rng_r In rng1
        If rng = rng_r Then
            result = rng_r.Value
        End If
    Next rng_r

    allvlookup = result

End Function

Upvotes: 1

Related Questions