cunningruss
New Member
- Joined
- Oct 31, 2012
- Messages
- 2
Learning VBA on the job, I'm not able to get the following code to work. Would appreciate some support. I receive Runtime error '91' at Line 6
Dim xlApp As New Excel.Application
Dim xlBook As Excel.WorkBook
Dim xlSheet As Excel.WorkSheet
Dim FoundCell As Range
xlApp.WorkBooks.Open ("C:\temp\inventory.xlsx")
xlBook.WorkSheets("Sheet1").Activate
Set xlSheet = xlBook.ActiveSheet
With xlSheet.Range("B3:B145")
Set FoundCell = .Find(What:=MyName, After:=.Cells(.Cells.Count), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
End With
.....
Dim xlApp As New Excel.Application
Dim xlBook As Excel.WorkBook
Dim xlSheet As Excel.WorkSheet
Dim FoundCell As Range
xlApp.WorkBooks.Open ("C:\temp\inventory.xlsx")
xlBook.WorkSheets("Sheet1").Activate
Set xlSheet = xlBook.ActiveSheet
With xlSheet.Range("B3:B145")
Set FoundCell = .Find(What:=MyName, After:=.Cells(.Cells.Count), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
End With
.....