Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default UDF returns #NUM! with F9 or Application.CalculateFull if sheet no

Does anyone know of a good tutorial on the best way to loop through
the values of a 2-D input range in a UDF?


See my reply to your later post. In short, you should pass a Range as
a parameter and do your calculations based on that range. In this
case, it doesn't matter which might be active when the calculation
takes place -- the Range parameter will always refer to the correct
worksheet. If for some reason you need to get the cell or worksheet on
which the UDF function was entered, you can use Application.Caller.
This will return a reference to the cell containing the formula. From
that, you can get a Worksheet reference and a Workbook reference.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Tue, 7 Apr 2009 21:40:00 -0700 (PDT), Greg
wrote:

I did some debugging and I found out that the loop "For Each Cell in
Subset Range" is looping through the cells in the worksheet that is
active at the time the macro is run, instead of the worksheet of the
cell that contains the function. I need to find a way to loop through
the values on the sheet where the function is located instead of the
active sheet at the time when the subroutine is run regardless of
which sheet is active when the workbook is recalculated.

Does anyone know of a good tutorial on the best way to loop through
the values of a 2-D input range in a UDF?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA calling a web application that returns XML stainless Excel Programming 4 June 1st 07 11:51 AM
Application.CalculateFull [email protected] Excel Programming 4 January 17th 07 08:22 PM
Is it necessary to use CalculateFull command when in automatic mod Carl Excel Discussion (Misc queries) 2 November 18th 06 06:22 PM
application.match Returns what ben Excel Programming 1 February 16th 05 10:39 PM
Application.Calculatefull function Charlie Woll Excel Programming 3 July 20th 03 07:46 PM


All times are GMT +1. The time now is 09:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"