get cell of function
What I actually want to do: Check the number of filled rows, left of the
cell I entered the function. And as soon as i got the number (perhaps I
can determine the number of filled cells in that row as limit [with a
loop]) of filled cells, I want to check, which one's got the biggest
value...
I could add an argument to the function, force the user to enter a
range. But that wouldn't be a challenge ;)
greez for help or something...
masterphil
Tom Ogilvy wrote:
first, application.Caller returns a rng reference, so you don't want to
convert it to an string address, the convert it back to a range.
The second is that EntireColumn is a singe entity, so there is nothing to
loop through
Just to illustrate in the immediate window:
? ActiveCell.EntireColumn.Count
1
so you have a column, not 65536 cells
Another thing is that it takes forever to loop through 65536 cells - surely
you don't want to do that. What do you want to do. Perhaps
set rng = Application.Caller
set r = rng.offset(0,-1)
set r = range(cells(1,r.column),cells(rows.count,r.column) .End(xlup))
For Each cell r
Next
If you do want the entire column then
For Each cell In Range(Application.Caller.Address) _
.Offset(0,-1).EntireColumn.Cells
'do something
Next cell
as Bob said, in a UDF used in a worksheet as a formula, you can't change
values or formatting in other cells, but you can read their values or
formating.
|