View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.newusers
Chip Pearson
 
Posts: n/a
Default Searching data in a column via Input Box

Chris,

Try some code like the following:

Dim FoundCell As Range
Dim WhatToFind As String
WhatToFind = InputBox("Find What?")
If WhatToFind = "" Then
Exit Sub
End If
Set FoundCell = Range("A1:A20").Find(what:=WhatToFind, _
LookIn:=xlValues, lookat:=xlWhole)
If Not FoundCell Is Nothing Then
FoundCell.Select
MsgBox WhatToFind & " found at " & FoundCell.Address
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Chris" wrote in message
...
Hello I am new to Excel VBA and think I have thrown myself into
the deep end
by trying to produce an advanced spreadsheet.

What I am trying to do is have a button on my spreadsheet that
when clicked
opens up an Input Box, the user can input some data and then it
searches a
column for the matching input.

For Example

Input Box "Hello"

I would like it to then search column A1:A20 for the Word
Hello. Once found
just leave the cell selected and a message box saying the word
has been found.

If anyone could do this for me I would be very greatful I have
tried now for
2 days and finding it really tough.

Thanks for the help