Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default SEARCHING A WORKBOOK ! !

Hello -

There are several sheets in a workbook. Apart from the first sheet named
"SHEET1" every sheet contains lots of strings (text, numbers, etc).

I need a macro that will loop through each sheet except "SHEET1",
searching for matches of the word or phrase in Range("A1") of "SHEET1".
Conditions:

1. The search match should not be case sensitive.

2. It is possible a match could be found in several cells on one sheet
AND/OR found in several other sheets.

3. For each match found on a sheet, the cell containing the match should
be selected. Then an option box should pop up and ask whether I want to
continue searching the rest of the sheets or return to "SHEET1"..(i.e
"Yes Continue Search", "No Return to SHEET1"). If no matches are found
in the workbook, popup box should just say "No matches found"

Any help would be appreciated!
Thanks
Jay




*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default SEARCHING A WORKBOOK ! !

Please refer this link from Chip Pearson..
http://www.cpearson.com/excel/RangeFind.htm

If this post helps click Yes
---------------
Jacob Skaria


"jay dean" wrote:

Hello -

There are several sheets in a workbook. Apart from the first sheet named
"SHEET1" every sheet contains lots of strings (text, numbers, etc).

I need a macro that will loop through each sheet except "SHEET1",
searching for matches of the word or phrase in Range("A1") of "SHEET1".
Conditions:

1. The search match should not be case sensitive.

2. It is possible a match could be found in several cells on one sheet
AND/OR found in several other sheets.

3. For each match found on a sheet, the cell containing the match should
be selected. Then an option box should pop up and ask whether I want to
continue searching the rest of the sheets or return to "SHEET1"..(i.e
"Yes Continue Search", "No Return to SHEET1"). If no matches are found
in the workbook, popup box should just say "No matches found"

Any help would be appreciated!
Thanks
Jay




*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default SEARCHING A WORKBOOK ! !

You could try something like this:

Sub Find_Value
MySheet = 1

Do Until MySheet = Sheets.Count + 1
Sheets(MySheet).Select
If ActiveSheet.Name = "Sheet1" Then
Goto Next_Sheet
End If

Next_Find:
Cells.Find What:="Sheet1", MatchCase:=False
If Activecell.Address = FirstMatch Then
Goto Next_Sheet
End If
If FirstMatch = "" Then
FirstMatch = Activecell.Address
End If
ValueFound = MsgBox("Have found value at " & Activecell.Address & ".
Continue search?",vbYesNo,"Search Sheets")
If ValueFound = vbYes Then
MsgBox("Search continuing")
Else
Goto End_Me
End If
Goto Next_Find

Next_Sheet:
FirstMatch = ""
MySheet = MySheet + 1
Loop

End_Me:

End Sub

You would probably also need to put in an error handler if the value wasn't
found at all on a sheet. If the value is going to be in a particular,
consistent column, you could just loop through the cells looking for the
value using the StrCompare statement.


"Jacob Skaria" wrote:

Please refer this link from Chip Pearson..
http://www.cpearson.com/excel/RangeFind.htm

If this post helps click Yes
---------------
Jacob Skaria


"jay dean" wrote:

Hello -

There are several sheets in a workbook. Apart from the first sheet named
"SHEET1" every sheet contains lots of strings (text, numbers, etc).

I need a macro that will loop through each sheet except "SHEET1",
searching for matches of the word or phrase in Range("A1") of "SHEET1".
Conditions:

1. The search match should not be case sensitive.

2. It is possible a match could be found in several cells on one sheet
AND/OR found in several other sheets.

3. For each match found on a sheet, the cell containing the match should
be selected. Then an option box should pop up and ask whether I want to
continue searching the rest of the sheets or return to "SHEET1"..(i.e
"Yes Continue Search", "No Return to SHEET1"). If no matches are found
in the workbook, popup box should just say "No matches found"

Any help would be appreciated!
Thanks
Jay




*** Sent via Developersdex http://www.developersdex.com ***

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
Searching for info in a separate workbook mailrail Excel Discussion (Misc queries) 0 October 4th 07 09:16 PM
searching all workbook sheets jamie Excel Worksheet Functions 0 June 12th 06 09:06 PM
workbook searching Juuljus Excel Programming 1 December 2nd 05 03:56 PM
Searching an Entire Workbook SlimSlender Excel Programming 1 December 11th 04 10:34 PM
Searching through several sheets in a workbook Tom Atkisson Excel Programming 1 September 19th 03 11:35 PM


All times are GMT +1. The time now is 02:42 PM.

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

About Us

"It's about Microsoft Excel"