View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel[_346_] joel[_346_] is offline
external usenet poster
 
Posts: 1
Default searching the entire workbook after scanning a Barcode


You didn't say what you wanted done with the results so I put the
addresses in a message box.

Sub FindBarCode()

BarCode = Sheets("Sheet1").Range("A1")

'skip sheet 1 and located all occurances of Bar Code
For Each sht In Sheets
If sht.Name < "Sheet1" Then
Set c = sht.Cells.Find(what:=BarCode, _
LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
FirstAddr = c.Address
Do
Set c = sht.Cells.FindNext(after:=c)
If Not c Is Nothing Then
MsgBox ("BarCode : " & BarCode & _
" found at location : " & c.Address(external:=True))
End If
Loop While Not c Is Nothing And c.Address < FirstAddr

End If
End If

Next sht

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=162180

Microsoft Office Help