Hi All,
I’m try to transfer a range name or cell address into a function so that it can be manipulated within the function.
My simplified test function is shown below:
[INDENT][COLOR=#0000ff]Function JunkTestAddress(rngA As Range)[/COLOR][/INDENT] [INDENT][COLOR=#0000ff] [/COLOR][/INDENT] [INDENT][COLOR=#0000ff]’ Usage: =JunkTestAddress(rngA)[/COLOR][/INDENT] [INDENT][COLOR=#0000ff]’ Where rngA = Named Range, eg Data Table with range $A$3:$C$12[/COLOR][/INDENT] [INDENT][COLOR=#0000ff] [/COLOR][/INDENT] [INDENT][COLOR=#0000ff]Dim Msg, Button, Title, Response As String[/COLOR][/INDENT] [INDENT][COLOR=#0000ff] [/COLOR][/INDENT] [INDENT][COLOR=#0000ff]JunkTestAddress = Application.WorksheetFunction.Address (1,Application.WorksheetFunction.Column(rngA), 4)[/COLOR][/INDENT] [INDENT][COLOR=#0000ff] [/COLOR][/INDENT] [INDENT][COLOR=#0000ff] Title = “JunkTestAddress Function…”[/COLOR][/INDENT] [INDENT][COLOR=#0000ff] Button = vbExclamation[/COLOR][/INDENT] [INDENT][COLOR=#0000ff] Msg = “rngA: ” & rngA & vbCrLf & _[/COLOR][/INDENT] [INDENT][COLOR=#0000ff] “JunkTest Address: ” & JunkTestAddress[/COLOR][/INDENT] [INDENT][COLOR=#0000ff] Response = MsgBox(Msg, Button, Title)[/COLOR][/INDENT] [INDENT][COLOR=#0000ff] [/COLOR][/INDENT] [INDENT][COLOR=#0000ff]End Function[/COLOR][/INDENT]
However it appears that the putting the Named Range or a cell address as the function parameter transfers the value contained in the cell to the function, rather than the cell/named range address, consequently the result returned by the function is #VALUE!
Here is my named range:
32381-20121116-JunkTestAddress-Data-Table
Commenting out the JunkTestAddress line results in the MessageBox displaying the value contained in cell referenced by rngA:
32382-20121116-JunkTestAddress-Dialogue
The result I am looking for is rngA = $C$3.
How can I transfer the function cell/range address parameter into the function so I can manipulate it? (Putting “” around rngA parameter when using the function and treating it as a string does not appear to resolve the issue.)
All assistance in resolving this will be appreciated.
Thanks in anticipation
BygAuldByrd