Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mac Lingo
 
Posts: n/a
Default Passing a WorkSheet from a Function???

I call the following function. It gets the correct Sheet in the
function, but the argument that Function passes
in
Set VARIABLE = Get_Sheet(...)
says "<No Variables" when I look at it in "Watch".

Function Get_Sheet(DirName, FileName, SheetName) As Worksheet
Workbooks(DirName, FileName).Open
Set Get_Sheet = Workbooks(FileName).Sheets(SheetName)
Workbooks(FileName).Close
End Function ' Get_Sheet


Any idea it doesn't work?


Tnx, Mac
Berkeley, CA



  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB
 
Posts: n/a
Default Passing a WorkSheet from a Function???

I had to change to open statement to

Workbooks.Open (DirName & FileName)

to work on my machine, but if it works fine on yours (are using Mac?)

Anyway, try not closing the source workbook, that seemed to work for me.

"Mac Lingo" wrote:

I call the following function. It gets the correct Sheet in the
function, but the argument that Function passes
in
Set VARIABLE = Get_Sheet(...)
says "<No Variables" when I look at it in "Watch".

Function Get_Sheet(DirName, FileName, SheetName) As Worksheet
Workbooks(DirName, FileName).Open
Set Get_Sheet = Workbooks(FileName).Sheets(SheetName)
Workbooks(FileName).Close
End Function ' Get_Sheet


Any idea it doesn't work?


Tnx, Mac
Berkeley, CA




  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JMB
 
Posts: n/a
Default Passing a WorkSheet from a Function???

Didn't catch the username first time around - never mind the first question!

"Mac Lingo" wrote:

I call the following function. It gets the correct Sheet in the
function, but the argument that Function passes
in
Set VARIABLE = Get_Sheet(...)
says "<No Variables" when I look at it in "Watch".

Function Get_Sheet(DirName, FileName, SheetName) As Worksheet
Workbooks(DirName, FileName).Open
Set Get_Sheet = Workbooks(FileName).Sheets(SheetName)
Workbooks(FileName).Close
End Function ' Get_Sheet


Any idea it doesn't work?


Tnx, Mac
Berkeley, CA




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default Passing a WorkSheet from a Function???

If you close the workbook that the Get_Sheet variable is pointing to, the
reference is destroyed. So what are you trying to do exactly?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Mac Lingo" wrote in message
.com...
I call the following function. It gets the correct Sheet in the
function, but the argument that Function passes
in
Set VARIABLE = Get_Sheet(...)
says "<No Variables" when I look at it in "Watch".

Function Get_Sheet(DirName, FileName, SheetName) As Worksheet
Workbooks(DirName, FileName).Open
Set Get_Sheet = Workbooks(FileName).Sheets(SheetName)
Workbooks(FileName).Close
End Function ' Get_Sheet


Any idea it doesn't work?


Tnx, Mac
Berkeley, CA





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
numerical integration integreat Excel Discussion (Misc queries) 4 May 12th 06 02:40 AM
Is there a worksheet function that will... Adam Kroger Excel Worksheet Functions 1 November 20th 05 07:41 PM
Comparing a list to a Calendar worksheet. PatrickL Excel Worksheet Functions 0 August 25th 05 04:21 PM
Worksheet function in excel only works once Divertor Chris Excel Worksheet Functions 1 July 27th 05 10:29 AM
Automatically up date time in a cell Mark Excel Discussion (Misc queries) 5 May 12th 05 12:26 AM


All times are GMT +1. The time now is 11:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"