Use of Address Formula within a UDF

SimonGeoghegan

Board Regular
Joined
Nov 5, 2013
Messages
66
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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,850
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,850
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,147,958
Messages
5,744,043
Members
423,843
Latest member
alex2022

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
Top