ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Return portion of Formula? (https://www.excelbanter.com/excel-discussion-misc-queries/215756-return-portion-formula.html)

Ken

Return portion of Formula?
 
Excel2003 ... Range D15:D54 now contains formulas similar to:

Cell D15 contains ... =MAX('Simpson, F'!R$15:R$300)
Cell D16 contains ... =MAX('Clause, S'!R$15:R$300))
Cell D17 contains ... =MAX('Alonglastname, C'!R$15:R$300))
etc (Name of WS chgs on each Row)

In Range A15:A54 ... I would like a Formula that will return the WS Name
contained in formula Range D15:D54.

A15 return "Simpson, F"
A16 return "Clause, S"
A17 return "Averylonglastname, C"

Thanks ... Kha


Gary''s Student

Return portion of Formula?
 
Try this one-line UDF:

Function sheetref(r As Range) As String
sheetref = Split(r.Formula, "'")(1)
End Function


UDFs are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the UDF will be saved with it.

To use the UDF from the normal Excel window, just enter it like a normal
Excel Function, for example =sheetref(D15)

To remove the UDF:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To learn more about UDFs, see:

http://www.cpearson.com/excel/Writin...ionsInVBA.aspx


--
Gary''s Student - gsnu200824


"Ken" wrote:

Excel2003 ... Range D15:D54 now contains formulas similar to:

Cell D15 contains ... =MAX('Simpson, F'!R$15:R$300)
Cell D16 contains ... =MAX('Clause, S'!R$15:R$300))
Cell D17 contains ... =MAX('Alonglastname, C'!R$15:R$300))
etc (Name of WS chgs on each Row)

In Range A15:A54 ... I would like a Formula that will return the WS Name
contained in formula Range D15:D54.

A15 return "Simpson, F"
A16 return "Clause, S"
A17 return "Averylonglastname, C"

Thanks ... Kha



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

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