Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Searching an Entire Workbook

Public Sub HighlightData()
Dim myDatum As Range, myRange As Range
Set myRange = Workbooks("List.xls").Worksheets("List").Range("Li st")

For Each myDatum In myRange
Windows("AllData.xls").Activate
Cells.Find(What:=myDatum, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, _
MatchCase:=False).Activate
On Error GoTo ErrorHandler

Selection.Font.Bold = True
With Selection.Interior
..ColorIndex = 6 'Yellow
..Pattern = xlSolid
End With
Next
ErrorHandler:
ActiveSheet.Next.Select
Resume
End Sub

Can someone help me refine this code? It works quite well, but I
would like to replace the Error Handling with code that says what
is actually supposed to be done - that is, to select the next
sheet when the item being looked for is not on the current sheet
since this is something that is expected and not actually an error.
Also, there is the small problem (error) of it trying to select
the next sheet after the last sheet.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 634
Default Searching an Entire Workbook

Apologies if you already knbew about it, but are you using a version of Excel
that doesn't allow you to select 'entire workbook' as the search area?

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"SlimSlender" wrote in message
ps.com...
Public Sub HighlightData()
Dim myDatum As Range, myRange As Range
Set myRange = Workbooks("List.xls").Worksheets("List").Range("Li st")

For Each myDatum In myRange
Windows("AllData.xls").Activate
Cells.Find(What:=myDatum, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, _
MatchCase:=False).Activate
On Error GoTo ErrorHandler

Selection.Font.Bold = True
With Selection.Interior
.ColorIndex = 6 'Yellow
.Pattern = xlSolid
End With
Next
ErrorHandler:
ActiveSheet.Next.Select
Resume
End Sub

Can someone help me refine this code? It works quite well, but I
would like to replace the Error Handling with code that says what
is actually supposed to be done - that is, to select the next
sheet when the item being looked for is not on the current sheet
since this is something that is expected and not actually an error.
Also, there is the small problem (error) of it trying to select
the next sheet after the last sheet.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.809 / Virus Database: 551 - Release Date: 09/12/2004


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 multiple fields and then print the entire row from resul Vegeta_matt18 Excel Worksheet Functions 2 July 22nd 09 01:36 AM
VLookup Not Searching the entire cell for Match LAP Excel Discussion (Misc queries) 3 February 23rd 07 05:40 PM
Relpace entire address with street name only, searching with wildc bclancy12 Excel Worksheet Functions 3 August 7th 06 09:33 PM
searching all workbook sheets jamie Excel Worksheet Functions 0 June 12th 06 09:06 PM
Identifying an item in one col/row and searching an entire spreads Bennie Excel Worksheet Functions 0 August 19th 05 01:49 AM


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