View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Comparing Cells in Workbooks

Hi Carlton,

Is it possible to add more than workbook. At the moment the program
includes one book:


Try:

Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range
Dim RngFound As Range
Dim arr As Variant
Dim i As Long

arr = Array("Book2.xls", "Book3.xls", "Book4.xls") '<<= CHANGE

Set rng = Range("A1:A10") '<<===== CHANGE

Application.ScreenUpdating = False

rng.Interior.ColorIndex = xlNone

For i = LBound(arr) To UBound(arr)
Set WB = Workbooks(arr(i))
For Each rCell In rng
If Not IsEmpty(rCell) Then
For Each SH In WB.Worksheets
Set RngFound = SH.Cells.Find( _
what:=rCell.Value, _
After:=SH.Range("A1"), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not RngFound Is Nothing Then
rCell.Interior.ColorIndex = 37
BlFound = True
Exit For
End If
Next SH
End If
Next rCell
Next i

Application.ScreenUpdating = True

End Sub


---
Regards,
Norman



"Carlton Patterson" wrote in message
...
Also,

Is it possible to add more than workbook. At the moment the program
includes one book:

Set WB = Workbooks("BOOK2.xls")


However, could I change the formula to include a few workbooks?

Cheers

Carlton


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