View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sonnich Sonnich is offline
external usenet poster
 
Posts: 13
Default pass workbook on to function?

I have a function which looks an item up in another workbook... the
work book is created as:
set lookup = workbooks.open....

later I try to use that in a function, as:
Function FindItem(item As String) As Boolean
' look for item in other document
j = iIndexStart
While (item < lookup.Sheets(1).Cells(j, 2)) And
(lookup.Sheets(1).Cells(j, 2) < "")
j = j + 1

Result: obejct not found

Trying passing it as a parameter does not compile

Function FindItem(item As String, loc as workbook) As Boolean
' look for item in other document
j = iIndexStart
While (item < loc.Sheets(1).Cells(j, 2)) And (loc.Sheets(1).Cells(j,
2) < "")
j = j + 1

what do I do wrong?