LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Seaching an excel sheet

pcorcele wrote:

I currently am using the following code to search my ecel sheet

[snip]
I would like to be able to input the search data in a TEXTbox and do
the same search.
Can anyone help with this


Put this in the sheet's class module and change "TextBox1" to the name of the
textbox:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If 13 = KeyCode Then
Dim UserResp As String
Dim MyText As String
Dim Cell As Range

UserResp = TextBox1.Text

Selection.SpecialCells(xlCellTypeComments).Select

For Each Cell In Selection
MyText = UCase$(Cell.Comment.Text)
If InStr(MyText, UCase$(UserResp)) Then
Cells(Cell.Row, 15).Value = UserResp
Cells(Cell.Row, 16).Value = Cell.Address
End If
Next Cell
End If
End Sub

(This is mostly just your code.)

If you want the textbox cleared after every search, add this immediately
before "End If":
TextBox1.Text = ""

--
Mr. Notlob, there's nothing wrong with you that an
expensive operation can't prolong.
 
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
Seaching Ex cel for text styles Jim in Fort Worth Texas Excel Programming 0 February 16th 10 07:25 PM
Seaching a range Robo Excel Discussion (Misc queries) 1 January 11th 10 10:04 AM
Seaching a Word Document from Excel Part ii VFXer Excel Programming 0 March 13th 08 07:09 PM
Seaching with no results Jean Excel Discussion (Misc queries) 3 March 20th 07 10:02 PM
Seaching across the top Ben H Excel Programming 4 February 16th 05 04:21 PM


All times are GMT +1. The time now is 01:01 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"