Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default passing an argument

this is a 2 part because i dont think the first part is possible

1) i'd like to have a function that has no arguments but references
the cell that the formula for the function is being input into and
just takes the value of the first non empty cell to the left (i dont
think its possible to reference the cell with the formula though???)

2) because of this i wrote the following passing one range variable
but i get a #value error, i know it has to do with the passing of the
range because if i hard code a cell it works fine for that row.

the code is:

Function diag(rng)
diag = Range("rng").End(xlToLeft)
End Function


any ideas????

thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default passing an argument

Try this:

function Diag(adrs as string) as string
diag = Range(adrs).end(xltoleft).address
end function

The input here is a string, eg "D7" and the result is a string containing
the address of the cell it finds.


" wrote:

this is a 2 part because i dont think the first part is possible

1) i'd like to have a function that has no arguments but references
the cell that the formula for the function is being input into and
just takes the value of the first non empty cell to the left (i dont
think its possible to reference the cell with the formula though???)

2) because of this i wrote the following passing one range variable
but i get a #value error, i know it has to do with the passing of the
range because if i hard code a cell it works fine for that row.

the code is:

Function diag(rng)
diag = Range("rng").End(xlToLeft)
End Function


any ideas????

thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default passing an argument


Function diag() As Variant
Application.Volatile
diag = Application.Caller.End(xlToLeft).Value
End Function

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




wrote in message
this is a 2 part because i dont think the first part is possible

1) i'd like to have a function that has no arguments but references
the cell that the formula for the function is being input into and
just takes the value of the first non empty cell to the left (i dont
think its possible to reference the cell with the formula though???)
2) because of this i wrote the following passing one range variable
but i get a #value error, i know it has to do with the passing of the
range because if i hard code a cell it works fine for that row.

the code is:
Function diag(rng)
diag = Range("rng").End(xlToLeft)
End Function
any ideas????
thanks
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default passing an argument

Function nextleft() As Variant
nextleft = ""
i = Application.Caller.Row
j = Application.Caller.Column - 1
For k = 1 To j
If Cells(i, k).Value = "" Then
Else
nextleft = Cells(i, k).Value
End If
Next
End Function

will do what you want, but it is not volatile. It is better to use args.
They will force re-calculation was values are added or removed.
--
Gary''s Student - gsnu2007c


" wrote:

this is a 2 part because i dont think the first part is possible

1) i'd like to have a function that has no arguments but references
the cell that the formula for the function is being input into and
just takes the value of the first non empty cell to the left (i dont
think its possible to reference the cell with the formula though???)

2) because of this i wrote the following passing one range variable
but i get a #value error, i know it has to do with the passing of the
range because if i hard code a cell it works fine for that row.

the code is:

Function diag(rng)
diag = Range("rng").End(xlToLeft)
End Function


any ideas????

thanks

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
Passing worksheet as an argument Marcusdmc Excel Programming 1 October 29th 07 12:57 PM
Passing a UDF as an argument to a UDF puff Excel Discussion (Misc queries) 3 February 23rd 06 09:46 PM
passing argument problem ?? ricksimm[_2_] Excel Programming 1 June 14th 05 12:30 AM
Passing argument to another Sub Roman Excel Programming 6 February 1st 05 09:17 PM
Need help passing an array as an argument blc[_3_] Excel Programming 3 August 4th 04 10:35 PM


All times are GMT +1. The time now is 07:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"