ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UDF argument problem (https://www.excelbanter.com/excel-programming/333452-udf-argument-problem.html)

[email protected]

UDF argument problem
 
I'm trying to do the following:

When you enter the following function:
=SDSUM(A1:B3,$B$1,B1B2)

I want the third argument in:
Function SDSUM(database, col, criteria)

named criteria, not to return whether B1B2 (True of False), but (just)
the string. However, I don't want to put quotation marks around it
because I want the user to click around in the worksheet to make
selections.

Any way to do this?

Thanks for any ideas.

Hessel


Tom Ogilvy

UDF argument problem
 
Public Function Test(sStr As String)
Dim sCrit As String
Set rng = Application.Caller
sCrit = rng.Formula
sCrit = Mid(sCrit, 7)
Test = Left(sCrit, Len(sCrit) - 1)
End Function

=Test(B1B2)

Returns B1B2
--
Regards,
Tom Ogilvy

wrote in message
oups.com...
I'm trying to do the following:

When you enter the following function:
=SDSUM(A1:B3,$B$1,B1B2)

I want the third argument in:
Function SDSUM(database, col, criteria)

named criteria, not to return whether B1B2 (True of False), but (just)
the string. However, I don't want to put quotation marks around it
because I want the user to click around in the worksheet to make
selections.

Any way to do this?

Thanks for any ideas.

Hessel




[email protected]

UDF argument problem
 
I would never have thought of using application.caller for this, but it
works!


Thanks a lot!



All times are GMT +1. The time now is 03:41 PM.

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