Experts Exchange connects you with the people and services you need so you can get back to work.
Dim iRowKey As Integer
Dim iRowDom As Integer
Dim iDomCount As Integer
Dim iRowMatches As Integer
Dim strKeyword As String
Dim strDomain As String
iDomCount = Selection.Row
iRowMatches = 2 ' set the next row for a matched item
iRowKey = 2 ' set the next row for a keyword to check
' get the next keyword
strKeyword = Cells(iRowKey, 2).Value
If strKeyword = "" Then
' see if it matches any domains
For iRowDom = iDomCount To 2 Step -1
strDomain = Cells(iRowDom, 1).Value
If strDomain = "" Then
If InStr(strDomain, strKeyword) > 0 Then
' keyword found, copy it
Cells(iRowMatches, 3).Value = strDomain
iRowMatches = iRowMatches + 1
' and delete the original
Cells(iRowDom, 1).Delete Shift:=xlUp
iDomCount = iDomCount - 1
iRowKey = iRowKey + 1
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.
Premium members get this course for $95.20.
Premium members get this course for $108.00.
Premium members get this course for $37.50.
Premium members get this course for $122.40.
Premium members get this course for $349.00.
Premium members get this course for $159.20.