LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Call to INDIRECT within user defined function

Cut down version of spreadsheet
Status Type
Col 4 Col 5
Row 6 Found A

Row 8 On Way A
Row 9 On Way G

Row 10 Bidding C
Row 11 Found B

I am trying to write a built in function which will look from one worksheet
to another, and return the number of occurences of a certain status against a
particular type.

I wrote the following function with a view to doing this, but all I get is a
VALUE error. I tried to use the Debug.Print but nothing appears in the
Immediate window when I get there and, infact, I can't look at the VBA window
until after the calculation has finished in the worksheet. I tried inserting
a breakpoint after the Debug.Print statement but even with that I don't get
anything displayed in the Immediate window. I am really having difficulty
with understanding how to use the Debug facility properly at all.

I have a thought that the basics of my problem is how I am calling INDIRECT
but I may be wrong in that too.

************

Function Type_Prospectives(fFR As Integer, fLR As Integer, fWSName As
String, _
fCAT As String, fTS As String) As Integer

Type_Prospectives = 0

Dim I As Integer
Dim IV1 As String
Dim IV2 As String
Dim TV1 As String
Dim TV2 As String

For I = fFR To fLR
IV1 = fWSName & "!R" & (Str(I)) & "C4"
IV2 = fWSName & "!R" & (Str(I)) & "C5"
TV1 = Application.WorksheetFunction.INDIRECT(IV1, False)
TV2 = Application.WorksheetFunction.INDIRECT(IV2, False)
Debug.Print I, IV1, IV2, TV1, TV2
If TV1 = fCAT Then
If TV2 = fTS Then
Type_Prospectives = Type_Prospectives + 1
End If
End If
Next I

************

Typical call to function (in full spreadsheet) reads as:
=Type_Prospectives(6,145,Inventory,"Found","A")

Three are three potential values of fCAT, and eleven of fTS, so I am looking
to call this 33 times in the full spreadsheet.

One other strange quirk that I would welcome insight on is the fact that
when I tried to have the function statement as a single line, VBA would not
even let me save - the line just went red and I could not proceed. When I
inserted the second line and used the underscore continuation character, it
was all OK, at least as regards the Function statement anyway.

Any advice welcome, please.

Best regards

Philip
 
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
How to call user defined function (UDF) from custom menu in Excel2003? Dutch_Guy Excel Programming 3 February 28th 08 03:59 PM
Call user defined function in an add-in Dale Fye Excel Programming 2 December 15th 06 05:04 PM
How to call a function of an user defined DLL from Excel? Davide[_2_] Excel Programming 3 May 9th 06 02:50 PM
Excel "Insert Formula" dialog always call my user defined function [email protected][_2_] Excel Programming 0 March 1st 06 02:35 AM
Call GoalSeek from a user-defined-function Mark Excel Programming 1 August 23rd 05 01:50 PM


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