View Single Post
 
Old 02-16-2017, 08:12 PM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Don't know how the second post would be an alternative to the first.
None the less, I think this will do what you indicate you're wanting as long as you're searching for text and not numbers.
Keep your fingers crossed and give it a try.
Code:
Sub Fugman_second_question()

    Dim str As String, ws As Worksheet
    Dim r As Long, col As Long
    
str = InputBox("Enter what to search for", "SEARCH CRITERIA")
If str = "" Then Exit Sub

Set ws = Sheets("Sheet1") '<~~ change to suit
col = 7     '<~~ 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

If r > 0 Then
    If ws.Cells(r + 1, col) = "" Then
        ws.Range("A1").Value = "not found"
    Else
        ws.Range("A1").Value = ws.Cells(r + 1, col).Value
    End If
Else
    MsgBox "Didn't find  " & str
End If

End Sub
Reply With Quote