PC Review


Reply
Thread Tools Rate Thread

Calling a user Function in Worksheet

 
 
rameshs319@gmail.com
Guest
Posts: n/a
 
      7th Feb 2008
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 With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      7th Feb 2008
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.

"(E-Mail Removed)" 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a public function from a worksheet JWirt Microsoft Excel Programming 5 19th Sep 2008 04:22 PM
calling a worksheet function from another worksheet in same workbo Liz Microsoft Excel Programming 5 23rd Jun 2008 06:16 PM
Calling VBA function from a worksheet Mike Microsoft Excel Programming 7 14th Jan 2008 08:26 PM
calling VBA function within a worksheet =?Utf-8?B?bWF0ZWxvdA==?= Microsoft Excel Programming 2 20th Mar 2006 06:45 PM
calling a function in a worksheet from a user form =?Utf-8?B?c3RldmU=?= Microsoft Excel Programming 1 19th Jan 2006 10:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:41 PM.