Option Explicit
Sub Find2()
'
' Find2 Macro
' Macro recorded 06/23/2005 by
'
Range("A5").Select
Cells.Find(What:="F00", after:=activeCell, LookIn:=xlValues, Lookat:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).activate
Dim Issue As String
Dim Date1 As String
Issue = Range("B3").Value
Date1 = Range("B2").Value
Do Until activeCell.Value = "F00----"
If activeCell.Value = "F00" Then
Cells.Find(What:="F00", after:=activeCell, LookIn:=xlValues, Lookat:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).activate
Else
Dim carry As String
carry = activeCell.Value
Dim oWB As Excel.Workbook
Dim i As Integer
Dim bFound As Boolean
For i = 1 To Application.Workbooks.Count
If Application.Workbooks(i).Name = "H:\rrusnak\Equipment Log.xls" Then
bFound = True
Exit For
End If
bFound = True
Next
If bFound = True Then
MsgBox "Open already"
Set oWB = Application.Workbooks("H:\rrusnak\Equipment Log.xls")
Else
MsgBox "Not Open"
Set oWB = Application.Workbooks.Open("H:\rrusnak\Equipment Log.xls")
End If
Dim finish As Boolean
Dim index As Integer
index = 1
finish = False
Do Until finish = True
If index = 12 Then
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "YTG Stock #" + carry + " Not Found" ' Define message.
Style = vbOKOnly + vbExclamation + vbDefaultButton1 ' Define buttons.
Title = "Stock Number Not Found" ' Define title.
Help = "DEMO.HLP" ' Define Help file.
Ctxt = 1000 ' Define topic
' context.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
End If
finish = True
Else
Worksheets(index).activate
Range("B4").Select
Do Until activeCell.Value = "" Or finish = True
If activeCell.Value = carry Then
activeCell([1], [2]).Select
activeCell = Issue
activeCell([1], [2]).Select
activeCell = Date1
finish = True
Else
activeCell.Offset([1], [0]).activate
End If
Loop
index = index + 1
End If
Loop
Windows("Material Reconciliation Slips.xls").activate
Cells.Find(What:="F00", after:=activeCell, LookIn:=xlValues, Lookat:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).activate
End If
Loop
Windows("Equipment Log.xls").activate
Worksheets(1).activate
Windows("Material Reconciliation Slips.xls").activate
End Sub