Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default custom function - finding cell address

i have a custom function that returns an array of values based on
several inputs. to implement this, a range of cells are highlighted,
the function is typed, and then ctrl + shift + enter keys are
entered. i would like to calculate the number of cells that are
required for the output so the user does not have to input this.
cannot use activecell, that only works when the function is created.
if the any of the arguments point to a cell, the function is
recaclulated when that cell changes. the activecell is then the
argument cell and not the cell that is being calculated. is it
possible to find what cell is being calculated during the
recalculation process?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default custom function - finding cell address

I am not sure, exactly what you need, but maybe this can help you:

Selection.Cells.Count
Selection.address

Maybe you should post your code for further comments.

Per

On 27 Nov., 02:38, extrnh wrote:
i have a custom function that returns an array of values based on
several inputs. *to implement this, a range of cells are highlighted,
the function is typed, and then ctrl + shift + enter keys are
entered. *i would like to calculate the number of cells that are
required for the output so the user does not have to input this.
cannot use activecell, that only works when the function is created.
if the any of the arguments point to a cell, the function is
recaclulated when that cell changes. *the activecell is then the
argument cell and not the cell that is being calculated. *is it
possible to find what cell is being calculated during the
recalculation process?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default custom function - finding cell address

On Nov 26, 8:38*pm, extrnh wrote:
i have a custom function that returns an array of values based on
several inputs. *to implement this, a range of cells are highlighted,
the function is typed, and then ctrl + shift + enter keys are
entered. *i would like to calculate the number of cells that are
required for the output so the user does not have to input this.
cannot use activecell, that only works when the function is created.
if the any of the arguments point to a cell, the function is
recaclulated when that cell changes. *the activecell is then the
argument cell and not the cell that is being calculated. *is it
possible to find what cell is being calculated during the
recalculation process?


Here is the code;

Public Function samplefunction(N As Long, A As Double, B As Double, G
As Double, _
D As Double, P As Long) As Variant()

' execute the samplefunction function and return the output as
column array

Dim dblX() As Double
Dim i As Long
Dim lngIerr As Long
Dim varTemp As Variant
'
ReDim dblX(0 To N - 1)
On Error Resume Next
Call samplefunction_vba(N, dblX(0), A, B, G, D, P, lngIerr)
If lngIerr < 0 Then ' error in dll - fill in output array with
error value
ReDim varTemp(1 To 1)
varTemp(1) = lngIerr
Else
ReDim varTemp(1 To N)
For i = 1 To N
varTemp(i) = dblX(i - 1)
Next i
End If
samplefunction = Application.Transpose(varTemp)

End Function


Again this is a custom function that returns an array of values. So a
FormulaArray is used when entering the function on the worksheet. N
is the number of cells in the output, which is the number of cells
that are highlighted when the FormulaArray is entered. I do not want
to require the user to input N, I want to be able to determine the
number of cells for the FormulaArray. Any ideas?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default custom function - finding cell address

Application.caller will return the range of cells that contain the formula.

If you use a multi-cell range (say A1:C9) and use an array formula like:

=myfunc(x99)
and array enter it, you could use:

Option Explicit
Function myFunc(rng As Range) As Variant

Dim HowManyRows As Long
Dim HowManyCols As Long

HowManyCols = Application.Caller.Columns.Count
HowManyRows = Application.Caller.Rows.Count

'some tests to see how to rearrange your output.
myfunc = ...

End Function



On 11/26/2010 19:38, extrnh wrote:
i have a custom function that returns an array of values based on
several inputs. to implement this, a range of cells are highlighted,
the function is typed, and then ctrl + shift + enter keys are
entered. i would like to calculate the number of cells that are
required for the output so the user does not have to input this.
cannot use activecell, that only works when the function is created.
if the any of the arguments point to a cell, the function is
recaclulated when that cell changes. the activecell is then the
argument cell and not the cell that is being calculated. is it
possible to find what cell is being calculated during the
recalculation process?


--
Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default custom function - finding cell address

On Nov 30, 7:45*am, Dave Peterson wrote:
Application.caller will return the range of cells that contain the formula.

If you use a multi-cell range (say A1:C9) and use an array formula like:

=myfunc(x99)
and array enter it, you could use:

Option Explicit
Function myFunc(rng As Range) As Variant

* * *Dim HowManyRows As Long
* * *Dim HowManyCols As Long

* * *HowManyCols = Application.Caller.Columns.Count
* * *HowManyRows = Application.Caller.Rows.Count

* * *'some tests to see how to rearrange your output.
* * *myfunc = ...

End Function

On 11/26/2010 19:38,extrnhwrote:

i have a custom function that returns an array of values based on
several inputs. *to implement this, a range of cells are highlighted,
the function is typed, and then ctrl + shift + enter keys are
entered. *i would like to calculate the number of cells that are
required for the output so the user does not have to input this.
cannot use activecell, that only works when the function is created.
if the any of the arguments point to a cell, the function is
recaclulated when that cell changes. *the activecell is then the
argument cell and not the cell that is being calculated. *is it
possible to find what cell is being calculated during the
recalculation process?


--
Dave Peterson


Dave:

Thank you very much, this is what I needed.

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
Finding Cell address by value default105 Excel Discussion (Misc queries) 2 June 30th 09 09:31 PM
Finding Cell address by value default105 Excel Discussion (Misc queries) 1 June 30th 09 11:05 AM
Finding the Address of a Cell tb Excel Worksheet Functions 5 December 13th 07 01:59 PM
creating custom function - need to receive a cell address as a par Mark VII Excel Programming 5 September 29th 06 08:06 PM
Finding cell address... korcutt Excel Programming 2 November 7th 05 10:50 PM


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