ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Get cell address from macro function argument (https://www.excelbanter.com/new-users-excel/91346-get-cell-address-macro-function-argument.html)

oscar

Get cell address from macro function argument
 
Is it possible to know the address of the cell that is passed as argument to
a macro function? I want to know this to compare to the cell next to the one
passed to the function.

Gary''s Student

Get cell address from macro function argument
 
Yes:

Function qwerty(r As Range) As Integer
MsgBox (r.Offset(0, 1).Address)
qwerty = 0
End Function



--
Gary's Student


"oscar" wrote:

Is it possible to know the address of the cell that is passed as argument to
a macro function? I want to know this to compare to the cell next to the one
passed to the function.


oscar

Get cell address from macro function argument
 
Thank you for your reply.

Is it possible to use that macro in the formula bar?
I tryed with =qwerty(A1) and I got #NAME?

Thank you for your time

"Gary''s Student" wrote:

Yes:

Function qwerty(r As Range) As Integer
MsgBox (r.Offset(0, 1).Address)
qwerty = 0
End Function



--
Gary's Student


"oscar" wrote:

Is it possible to know the address of the cell that is passed as argument to
a macro function? I want to know this to compare to the cell next to the one
passed to the function.


Gary''s Student

Get cell address from macro function argument
 
Yes you can.

First you need to copy the 4 line function and paste it in VBA editor. See:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
Gary's Student


"oscar" wrote:

Thank you for your reply.

Is it possible to use that macro in the formula bar?
I tryed with =qwerty(A1) and I got #NAME?

Thank you for your time

"Gary''s Student" wrote:

Yes:

Function qwerty(r As Range) As Integer
MsgBox (r.Offset(0, 1).Address)
qwerty = 0
End Function



--
Gary's Student


"oscar" wrote:

Is it possible to know the address of the cell that is passed as argument to
a macro function? I want to know this to compare to the cell next to the one
passed to the function.



All times are GMT +1. The time now is 01:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com