I have two types of data in two separate columns.One column have some results in it. I want to compare some specific words which are in column 1 with column 2 and want to get that result in another column. I am giving one example of it.
Column1 Column2 Column3
Senior secured loans percentage of senior secured loans SSL
I want to get the result “SSL” for all those data in the column 2 which consists senior secured.
Here is the VBA code to match a string and print the result.
Sub sbMatchStringInColumn() lRow = 500 'This is your last row with data in the sheet/specific column For iCntr = 1 To lRow 'This will check if column B values contains a sting and print in Column C If InStr(1, Range("B" & iCntr), "senior secured") Then Range("C" & iCntr) = "SSL" 'If you want to check in both A & B Columns see the below statement 'If (InStr(1, Range("A" & iCntr), "senior secured") And InStr(1, Range("B" & iCntr), "senior secured")) Then Range("C" & iCntr) = "SSL" Next iCntr End Sub