#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Search Tool


Hi all,

I have a large spreadsheet with cols A-G that contain data. I am tryin
to implement a search tool on the spreadsheet - I can enter a string an
then press cmdButton and then it will find it for me. This work usin
the following code;


Code
-------------------

Private Sub cmdSearchSheet_Click()

Dim searchString As String, i%

searchString = txtSearch.Text

Application.ScreenUpdating = False

Columns("A:G").Select
Selection.Find(What:=searchString, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Select

Application.ScreenUpdating = True

ActiveCell.Select

End Sub

-------------------


My problem is - how do I carry on searching (Find Next) the strin
within these columns, so it searching for every instance of th
searchString and not just the first one..

TIA, any ideas appreciated

--
gti_jober
-----------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...fo&userid=3063
View this thread: http://www.excelforum.com/showthread.php?threadid=52912

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Search Tool


Hello again,

I have now produced the following - it works but could possibly b
coded more efficiently;


Code
-------------------

Option Explicit
Dim counter As Long

-------------------



Code
-------------------

Private Sub cmdSearchSheet_Click()

Dim searchString As String, i%
counter = counter + 1
searchString = txtSearch.Text

Application.ScreenUpdating = False

Columns("A:G").Select

If counter 1 Then
Selection.Find(What:=searchString, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
For i = 1 To counter
Selection.FindNext(After:=ActiveCell).Activate
Next i
Else
Selection.Find(What:=searchString, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
End If

Application.ScreenUpdating = True

ActiveCell.Select

End Sub

-------------------

--
gti_jober
-----------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...fo&userid=3063
View this thread: http://www.excelforum.com/showthread.php?threadid=52912

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Search Tool


This code is more efficient - works perfectly too;


Code:
--------------------

Private Sub cmdSearchSheet_Click()

Dim searchString As String, i%
counter = counter + 1
searchString = txtSearch.Text

Application.ScreenUpdating = False

Columns("A:G").Select

If counter = 1 Then
Selection.Find(What:=searchString, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Else
For i = 1 To counter
Selection.FindNext(After:=ActiveCell).Activate
Next i
End If

Application.ScreenUpdating = True

ActiveCell.Select

End Sub

--------------------


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=529122

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
Search Tool [email protected] Excel Discussion (Misc queries) 2 October 31st 06 02:57 PM
building a search tool Obi-Wan Kenobi Excel Programming 1 March 18th 06 03:23 PM
build a search tool in excel Obi-Wan Kenobi Excel Discussion (Misc queries) 1 March 18th 06 03:21 PM
Build a search tool in excel Obi-Wan Kenobi Excel Worksheet Functions 1 March 17th 06 11:03 PM
Excel newsgroup search tool [email protected] Excel Programming 2 November 11th 05 03:02 PM


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