Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
lister_d_000169
 
Posts: n/a
Default Custom Function not updating


I have a rather sizeable workbook that contains a lot of sales info.
Split by week, by measure in rows. I have a summary sheet that has a
dropdown for a week to be selected. this pulls through to another
sheet to calcuate a YTD sum from the sales info.

I wrote a custom function that takes the week entered and then uses
that value to offset back up teh sheet and add the reqd values and put
the result in the selected cell.

Function YTD(WeekNum As Integer)

Dim x, offsetnum As Integer
Dim YTDValue As Double

x = 1
offsetnum = -1328
YTDValue = 0

For x = 1 To WeekNum


YTDValue = YTDValue + ActiveCell.Offset(offsetnum, 0).Value
offsetnum = offsetnum + 16

Next

YTD = YTDValue

End Function

the function works fine if i manually enter it into the cells. If
however i change th week number the formula does not update, i get
#value!. my suspicion is because the function is setup using
Activecell.offset and those cells are not active.

anyone have any ideas??


--
lister_d_000169
------------------------------------------------------------------------
lister_d_000169's Profile: http://www.excelforum.com/member.php...o&userid=32950
View this thread: http://www.excelforum.com/showthread...hreadid=527771

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Charles Williams
 
Posts: n/a
Default Custom Function not updating

suggest you:

Add Application.Volatile to your function if you cannot find a way of of
entering the offset cell as a function argument.

replace activecell with application.caller so that the function is working
from the cell that contains it rather than whatevere the active cell happens
to be.

Charles
______________________
Decision Models
FastExcel 2.2 Beta now available
www.DecisionModels.com

"lister_d_000169"
<lister_d_000169.25g50v_1143661227.8584@excelfor um-nospam.com wrote in
message news:lister_d_000169.25g50v_1143661227.8584@excelf orum-nospam.com...

I have a rather sizeable workbook that contains a lot of sales info.
Split by week, by measure in rows. I have a summary sheet that has a
dropdown for a week to be selected. this pulls through to another
sheet to calcuate a YTD sum from the sales info.

I wrote a custom function that takes the week entered and then uses
that value to offset back up teh sheet and add the reqd values and put
the result in the selected cell.

Function YTD(WeekNum As Integer)

Dim x, offsetnum As Integer
Dim YTDValue As Double

x = 1
offsetnum = -1328
YTDValue = 0

For x = 1 To WeekNum


YTDValue = YTDValue + ActiveCell.Offset(offsetnum, 0).Value
offsetnum = offsetnum + 16

Next

YTD = YTDValue

End Function

the function works fine if i manually enter it into the cells. If
however i change th week number the formula does not update, i get
#value!. my suspicion is because the function is setup using
Activecell.offset and those cells are not active.

anyone have any ideas??


--
lister_d_000169
------------------------------------------------------------------------
lister_d_000169's Profile:
http://www.excelforum.com/member.php...o&userid=32950
View this thread: http://www.excelforum.com/showthread...hreadid=527771



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
lister_d_000169
 
Posts: n/a
Default Custom Function not updating


Charles

you are a legend !!!! application.caller did the job

many thanks

rgds

mark


--
lister_d_000169
------------------------------------------------------------------------
lister_d_000169's Profile: http://www.excelforum.com/member.php...o&userid=32950
View this thread: http://www.excelforum.com/showthread...hreadid=527771

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
Can a function return a Null (blank ) value? Maybe a custom functi colin_e Excel Worksheet Functions 2 March 16th 06 02:36 PM
Need help with automating the updating of a function in worksheet [email protected] Excel Worksheet Functions 4 February 10th 06 03:33 PM
Custom Function SPeterson Excel Discussion (Misc queries) 3 December 21st 05 07:12 PM
VBA Custom function for lookup Sami82 Excel Worksheet Functions 9 September 12th 05 03:20 PM
Date & Time mully New Users to Excel 4 May 23rd 05 11:56 AM


All times are GMT +1. The time now is 11:34 PM.

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

About Us

"It's about Microsoft Excel"