Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Return position for each matching value in entire workbook?

Is there a function or command for a cell in a worksheet that results in a
search of the entire Excel workbook and which then returns (in the worksheet)
the full value / content of each cell in the workbook that matches the
criteria of the search. For example, on one worksheet I want to see every
cell (in its entirety) of the workbook that contains a particular number or
phrase.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 296
Default Return position for each matching value in entire workbook?

You don't say how many typical finds you expect. In extremis, if you
want to list all matches on a single sheet then you could record 65536
times 256, matches. What happens if the rest of the 255 sheets contain
more matches than can be recorded on one sheet.

However if your matches are likely to be more modest, no more than
65535 then the following macro will list the sheet name and the cell
addresses in a sheet called "List"

Watch the word wrap in the line beginning "Worksheets("List")", it's
all one line and ends with "& stAddress"

The value this finds is a string called "test". See the first line of
code. You'll probably want to modify the macro with an input box so
that you can easily change this at runtime.

HTH


Sub MyFind()
Dim stFirstAddress As String, stAddress As String
Dim vaFind As Variant
Dim iSheets As Integer
Dim x As Integer

vaFind = "test"
iSheets = ActiveWorkbook.Sheets.Count

For x = 1 To iSheets
If Worksheets(x).Name < "List" Then
Worksheets(x).Activate
On Error Resume Next
Cells.Select
stFirstAddress = Selection.Find(What:=vaFind,
After:=Range("A1")).Address
Selection.Find(What:=vaFind, After:=ActiveCell).Activate

Do Until stAddress = stFirstAddress
stAddress = ActiveCell.Address
Worksheets("List").Range("A65536").End(xlUp).Offse t(1,
0) = Worksheets(x).Name & " " & stAddress
Selection.Find(What:=vaFind,
After:=ActiveCell).Activate
stAddress = ActiveCell.Address
Loop
End If
Next
End Sub




On Fri, 15 Sep 2006 11:42:01 -0700, Squidman
wrote:

Is there a function or command for a cell in a worksheet that results in a
search of the entire Excel workbook and which then returns (in the worksheet)
the full value / content of each cell in the workbook that matches the
criteria of the search. For example, on one worksheet I want to see every
cell (in its entirety) of the workbook that contains a particular number or
phrase.


__
Richard Buttrey
Grappenhall, Cheshire, UK
__________________________
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
Return all matching values [email protected] Excel Worksheet Functions 4 August 9th 06 04:02 AM
Set 'Print Entire Workbook' as default? Mike Excel Discussion (Misc queries) 0 April 5th 06 09:23 PM
Saving an entire workbook as a PDF using VBSCript Who be dat? Excel Worksheet Functions 4 March 20th 06 07:09 PM
printing entire workbook loralei Excel Discussion (Misc queries) 1 March 9th 06 11:35 PM
print entire workbook default KatGat01 Excel Discussion (Misc queries) 3 December 14th 04 10:12 PM


All times are GMT +1. The time now is 12:10 AM.

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"