Use of Address Formula within a UDF

SimonGeoghegan

Board Regular
Joined
Nov 5, 2013
Messages
68
Hi All,

I have a spreadsheet i'm using which has dates within different columns. I need to be able to identify the last cell in each row, which I have managed to do via:

Excel Formula:
=ADDRESS(ROW(A3),MAX((D3:V3<>"")*COLUMN(D3:V3)),1)

For example, providing me with "$E$3"

From there, I have a UDF called "GetComment" (which I found from this site) that extracts the text from a comment within this cell. Unfortunately, when I wrap this UDF around the above code, it presents as #VALUE!.

If I use the UDF with the cell reference, it works;

Excel Formula:
=getComment(E3)

However, used with the Address formula above, it doesnt work;

Excel Formula:
=getComment(ADDRESS(ROW(A3),MAX((D3:V3<>"")*COLUMN(D3:V3)),1))

Does anyone have any ideas on this at all? Perhaps there is something I need to change within the UDF to refine it?

UDF Code below.

VBA Code:
Function getComment(xCell As Range) As String
'UpdatebyExtendoffice20180330
On Error Resume Next
getComment = xCell.Comment.Text
End Function

Help appreciated as always, thanks.
Simon
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
You are passing the function a string & not a cell, so try
VBA Code:
Function getComment(xCell As String) As String
On Error Resume Next
getComment = Range(xCell).Comment.Text
End Function
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,175
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top