Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can use a string to pass a workbook name:
Sub Macro1() Dim s As String s = "Book2" Call bringup(s) End Sub Sub bringup(s As String) Dim w As Workbook Workbooks(s).Activate End Sub There are similar ways to convert string into worksheets, strings in ranges, etc. -- Gary's Student "Sonnich" wrote: 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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
pass variable from one workbook to another | Excel Discussion (Misc queries) | |||
Pass workbook name to ActiveX DLL (VB6) | Excel Discussion (Misc queries) | |||
pass workbook name to sub | Excel Programming | |||
<Pass the Torch from a Closing Workbook | Excel Programming | |||
<Pass the Torch from a Closing Workbook | Excel Programming |