Your technology certification is waiting. Enroll in Cloud Class ®
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
This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.