View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] rameshs319@gmail.com is offline
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