ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting UDF to run against the sheet it's been entered on... (https://www.excelbanter.com/excel-programming/399074-getting-udf-run-against-sheet-its-been-entered.html)

George

Getting UDF to run against the sheet it's been entered on...
 
I've got a problem with a UDF that I've written where it's running against
the active sheet, rather than the sheet that it's been entered on.

Is there anyway to limit the function so that it runs against the sheet it
was entered on rather than running against the active sheet?

I've tried looking around for this and have discovered the following which
don't seem to work...unless I'm using them wrong :-)

Application.Caller
Application.ThisCell.Worksheet

Any ideas?

Thanks

JW[_2_]

Getting UDF to run against the sheet it's been entered on...
 
Can you post up your UDF code?
George wrote:
I've got a problem with a UDF that I've written where it's running against
the active sheet, rather than the sheet that it's been entered on.

Is there anyway to limit the function so that it runs against the sheet it
was entered on rather than running against the active sheet?

I've tried looking around for this and have discovered the following which
don't seem to work...unless I'm using them wrong :-)

Application.Caller
Application.ThisCell.Worksheet

Any ideas?

Thanks



Randy Harmelink

Getting UDF to run against the sheet it's been entered on...
 
So close -- try something along these lines:

Function ShowIt()
Application.Volatile
ShowIt = Sheets(Application.Caller.Worksheet.Name).Range("A 1")
End Function

On Oct 10, 9:29 am, George wrote:
I've got a problem with a UDF that I've written where it's running against
the active sheet, rather than the sheet that it's been entered on.

Is there anyway to limit the function so that it runs against the sheet it
was entered on rather than running against the active sheet?

I've tried looking around for this and have discovered the following which
don't seem to work...unless I'm using them wrong :-)

Application.Caller
Application.ThisCell.Worksheet

Any ideas?




All times are GMT +1. The time now is 01:32 PM.

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