Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Error 1004 : function returning a Worksheet

Hello !

I'm experiencing an error after a function call returning a Worksheet
reference.

The function reads like this :

Private Function TheSheet(lSheet AS enmSheet) AS Worksheet

Select Case lSheet
Case enmEmpTable
Set TheSheet = ThisWorkbook.Sheets("Employees")

Case enmGlobal
Set TheSheet = Workbooks(sGlobal).Sheets("Parms")

....


End Function


Now, in another procedure, I use the following statement to get a
specific cell value :

vCellVal = TheSheet(lSheet).Cells(lRow, iCol).Value

This lines gives an error 1004 : Error defined by application or
object.

Tracing the code shows that the "TheSheet" function is executing
correctly and returns a valid reference to an existing worksheet.

iRow and iCol values are valid and the referred cell contains a text
value.

Any idea ?
Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Error 1004 : function returning a Worksheet

Michel,

In your explanation you refer to both "iRow" and "lRow". Could that be the
problem?

hth,

Doug

"Michel S." wrote in message
...
Hello !

I'm experiencing an error after a function call returning a Worksheet
reference.

The function reads like this :

Private Function TheSheet(lSheet AS enmSheet) AS Worksheet

Select Case lSheet
Case enmEmpTable
Set TheSheet = ThisWorkbook.Sheets("Employees")

Case enmGlobal
Set TheSheet = Workbooks(sGlobal).Sheets("Parms")

....


End Function


Now, in another procedure, I use the following statement to get a specific
cell value :

vCellVal = TheSheet(lSheet).Cells(lRow, iCol).Value

This lines gives an error 1004 : Error defined by application or object.

Tracing the code shows that the "TheSheet" function is executing correctly
and returns a valid reference to an existing worksheet.

iRow and iCol values are valid and the referred cell contains a text
value.

Any idea ?
Thanks




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Error 1004 : function returning a Worksheet

Thanks Doug

Unfortunately, it's only a typo. Both should read iRow

====

BTW : I forgot to specify I'm using Excel 2003



Doug Glancy a écrit :
Michel,

In your explanation you refer to both "iRow" and "lRow". Could that be the
problem?

hth,

Doug

"Michel S." wrote in message
...
Hello !

I'm experiencing an error after a function call returning a Worksheet
reference.

The function reads like this :

Private Function TheSheet(lSheet AS enmSheet) AS Worksheet

Select Case lSheet
Case enmEmpTable
Set TheSheet = ThisWorkbook.Sheets("Employees")

Case enmGlobal
Set TheSheet = Workbooks(sGlobal).Sheets("Parms")

....

End Function

Now, in another procedure, I use the following statement to get a specific
cell value :

vCellVal = TheSheet(lSheet).Cells(lRow, iCol).Value

This lines gives an error 1004 : Error defined by application or object.

Tracing the code shows that the "TheSheet" function is executing correctly
and returns a valid reference to an existing worksheet.

iRow and iCol values are valid and the referred cell contains a text value.

Any idea ?
Thanks




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
Run-time error '1004' for looking up date in worksheet [email protected] Excel Programming 5 December 4th 06 04:57 AM
Nested if returning error 1004 tom[_7_] Excel Programming 2 February 2nd 06 08:50 PM
Error 1004 in Excel 97 when trying to unprotect a worksheet glyn Excel Programming 0 January 27th 06 02:32 PM
Error 1004 from worksheet activate procedure mikeburg[_9_] Excel Programming 1 July 14th 05 01:25 AM
Set worksheet range runtime error 1004 DaveP Excel Programming 1 March 29th 05 07:13 AM


All times are GMT +1. The time now is 01:37 PM.

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

About Us

"It's about Microsoft Excel"