Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Out of context error in user defined function

Apologies to anyone who has already read this in Functions. I realised after
a few daysa of no response that I had posted in the wrong stream.

Excel 2007 query

Error received in VBA window (Debug) = <Out of Context
Error on Spreadsheet = #VALUE#

I have 'formatted' this function in much the same way as my twenty or more
other functions in this spreadsheet, yet I end up with Out of Context. I
have tried various approaches including an 'On Calculate' called sub-routine,
but all to no avail. The code for the function is stored in Module1 of an
xlam, which is where all my other working functions are also located.

Please Help.

Cut down summary of workbook

Worksheet 1 (Name = "Inventory")
Column C (3) €“ Alphabetic List of Titles, e.g.
AIR AND WATER
AIRCRAFT
INSECTS
ROBOTS
SOUND
SUPERSONIC JETS
VIKINGS
Column K (11) €“ Function built summary of holdings, examples of end values
CG
None Held
CGIJ
L
G
None Held
C

Worksheet 7 (Name = "None Held")
Row 1 €“ column values separated by semi-colons for the purposes of this
extracted summary -
"Title";5;6;163;19

Row 2 and subsequent 20 rows, call to function that is not working

Call text is
=Locate_None_Helds(B1+1,$D$1,ROW(),$E$1,SHEETNAME( 1),SHEETNAME())
Text of Function =

Function Locate_None_Helds(fFR As Long, fLR As Long, fCR As Long, fCNH As
Long, _
fWSName1 As String, fWSName2 As String) As String

Application.Volatile

Locate_None_Helds = ""

Dim tStatus As String
Dim fTitle As String


Dim I As Long
Dim J As Long
Dim K As Long


K = fCNH + 1
J = fCR

If fCR K Then

Locate_None_Helds = ""

Else

For I = fFR To fLR

tStatus = Worksheets(fWSName1).Cells(I, 11).Value
fTitle = Worksheets(fWSName1).Cells(I, 3).Value

If tStatus = "None Held" Then
Worksheets(fWSName2).Cells(J, 2) = I
Locate_None_Helds = fTitle
Exit For
End If

Next I

End If

End Function
Every time it gets to €“ Locate_None_Helds = fTitle
the error <Out of Context arises, and I just don't understand why.

In my many other functions I use exactly the same idea of assigning a value
to the name of the function, and that assigned value is what ends up in the
calling cell, but on this occasion it won't work and I just don't understand
why.

Please help.
With many thanks in anticipation
Philip, Perth, Western Australia
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
Error Calling A subroutine from a User Defined Function (UDF) that Carlos[_8_] Excel Programming 2 August 25th 08 07:16 PM
User Defined Function giving #NAME? error I need help please Excel Programming 15 April 19th 07 06:10 PM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
#Name? Error in User Defined VB Function idgity Excel Worksheet Functions 2 August 30th 05 08:58 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM


All times are GMT +1. The time now is 12:49 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"