Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Calling a user Function in Worksheet

Hi....

I am creating an application wherein the data's are present in column
A. Based on the entries in column A, there are a set of formulas to
calculate the result.

i created functions to do this operation. "Line_ID_mm" is one such
function.
When calling this function in worksheet as per the below procedure, it
returns an error #Value.

when executing calculation steps, it doesn't read the value in column
C3, as the Excel function Vlookup reads and returns the required.

What needs to be done in the function to get it resolved.

See the code below:

For calling the Function:

Set proj_sht1 = Workbooks("sample.xls").Sheets("test")
n = Application.CountA(proj_sht1.Range("A:A")) - 1

proj_sht1.Range("O3:O" & n).Formula =
"=Line_ID_mm(VLOOKUP(B3,linesize_in_mm,2,FALSE),C3 )"

Function:

Function Line_ID_mm(Line_size As Integer, Line_Sch As Variant) As
Single

Dim row_num As Integer

row_num = WorksheetFunction.Match(Line_size & Line_Sch,
Range("Sch_num"), 0)
Line_ID_mm = WorksheetFunction.Index(Range("pipe_id_num"), row_num, 8)

End Function

Please advice

S.Ramesh

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Calling a user Function in Worksheet

I would break the problem into two parts. first check that the formula is
correct on the worksheet. Click cell O3 and check that the formula is
correct (look at fx box). If this is correct then set a break point in the
function Line_ID_mm. Click on first line of code and press F9 in VBA window.
Then go back to worksheet and click on cell O3. Then go to fx box and
click on end of formula and press Enter on Keyboard.

The first line of code in the VBA window should know be highlight. You can
add each of the parameters of the function (Line_size and Line_Sch ) to the
watch window by highlighting these variables with the mouse and right click.
then select add to watch. You can also step through the code by pressing F8.

" wrote:

Hi....

I am creating an application wherein the data's are present in column
A. Based on the entries in column A, there are a set of formulas to
calculate the result.

i created functions to do this operation. "Line_ID_mm" is one such
function.
When calling this function in worksheet as per the below procedure, it
returns an error #Value.

when executing calculation steps, it doesn't read the value in column
C3, as the Excel function Vlookup reads and returns the required.

What needs to be done in the function to get it resolved.

See the code below:

For calling the Function:

Set proj_sht1 = Workbooks("sample.xls").Sheets("test")
n = Application.CountA(proj_sht1.Range("A:A")) - 1

proj_sht1.Range("O3:O" & n).Formula =
"=Line_ID_mm(VLOOKUP(B3,linesize_in_mm,2,FALSE),C3 )"

Function:

Function Line_ID_mm(Line_size As Integer, Line_Sch As Variant) As
Single

Dim row_num As Integer

row_num = WorksheetFunction.Match(Line_size & Line_Sch,
Range("Sch_num"), 0)
Line_ID_mm = WorksheetFunction.Index(Range("pipe_id_num"), row_num, 8)

End Function

Please advice

S.Ramesh


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
Calling VBA function from a worksheet Mike Excel Programming 1 January 14th 08 05:15 PM
Calling Excel user defined function from C# Stanley Excel Programming 0 June 26th 06 02:16 PM
Calling user defined function from C/C++ Ravil Excel Programming 0 April 24th 06 06:05 PM
calling VBA function within a worksheet matelot Excel Programming 2 March 20th 06 06:45 PM
calling a function in a worksheet from a user form steve Excel Programming 1 January 19th 06 10:00 PM


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