Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
Chris
 
Posts: n/a
Default Searching data in a column via Input Box

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
  #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



  #3   Report Post  
Posted to microsoft.public.excel.newusers
Chris
 
Posts: n/a
Default Searching data in a column via Input Box

Thanks Chip however I found a solution and modified it to what I wanted its
pretty cool. Seperated into two different modules. Thanks for your time and
the reply.

Chris

"Chip Pearson" wrote:

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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel: How to choose data on two separate rows in the same column RicardoE Excel Worksheet Functions 2 February 24th 06 12:41 AM
ranking query JaimeTimbrell Excel Discussion (Misc queries) 2 February 16th 06 08:09 AM
Return SEARCHED Column Number of Numeric Label and Value Sam via OfficeKB.com Excel Worksheet Functions 23 January 30th 06 06:16 PM
Searching for partial data in a column Severin Excel Discussion (Misc queries) 2 October 3rd 05 06:33 PM
Sort pages? David Excel Discussion (Misc queries) 15 May 13th 05 11:33 PM


All times are GMT +1. The time now is 07:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"