NoSparks
Sorry that it has taken me so long to reply, but it has been busy here.
Once again, you delivered in spades. Thank you.
Actually, the second method is a better solution than the first. The data source for my activity is two fold. The second approach was chosen after I discovered the 2nd source. Using the code you provided eliminates a manual intermediate step in my process. This accomplished by using multiple "if-than-else" in your code.
EXAMPLE
str = "Address"
'str = InputBox("Enter what to search for", "SEARCH CRITERIA")
If str = "" Then Exit Sub
Set ws = Sheets("DATA ENTRY") '<~~ change to suit
col = 1 '<~~ change to suit ~~~ column 7 is "G"
On Error Resume Next 'if nothing found it errors
r = Application.WorksheetFunction.Match(str, ws.Columns(col), 0)
On Error GoTo 0 'turn error notification back on
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
If r > 0 Then
If ws.Cells(r + 1, col) = "" Then
ws.Range("I8").Value = "not found"
Else
ws.Range("I8").Value = ws.Cells(r + 1, col).Value
End If
Else
MsgBox "Didn't find " & str
End If
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X
'CITY
If r > 0 Then
If ws.Cells(r + 2, col) = "" Then
ws.Range("I9").Value = "not found"
Else
ws.Range("I9").Value = ws.Cells(r + 2, col).Value
End If
Else
MsgBox "Didn't find " & str
End If
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X
'STATE
If r > 0 Then
If ws.Cells(r + 3, col) = "" Then
ws.Range("I11").Value = "not found"
Else
ws.Range("I11").Value = ws.Cells(r + 3, col).Value
End If
Else
MsgBox "Didn't find " & str
End If
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X
'ZIPCODE
If r > 0 Then
If ws.Cells(r + 4, col) = "" Then
ws.Range("I12").Value = "not found"
Else
ws.Range("I12").Value = ws.Cells(r + 4, col).Value
End If
Else
MsgBox "Didn't find " & str
End If
Thanks again.
|