Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50090

Compare values in column a to column b, and put it in column c if they match

$
0
0
i'm trying to compare a value from column a to every value in column b, if they match, then copy that value to column c

right now i have a function that will check column b and return a true/false if you send it a value to match it
trying to figure out how i can run a function in to then take the true/false function and copy the first column value to column c

any help would be appreciated

thanks
Code:

Function IsInListB(theWord As String)
    'it returns true if a match is found
    'it returns false if a match is not found
       
    Dim isMatch As Boolean
    isMatch = False                        'assuming not in list at the beginning
       
    Range("B2").Select
    Do While ActiveCell.Value <> ""        'continue checking as long as column B is not blank
        If ActiveCell.Value = theWord Then  'got a match
            isMatch = True                  'so set isMatch to true
        End If
        ActiveCell.Offset(1, 0).Select      'go down one cell in column B
    Loop
   
    IsInListB = isMatch                    'send true or false to calling sub procedure
   
End Function

Attached Files

Viewing all articles
Browse latest Browse all 50090

Trending Articles