A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Function isn't recalculating



 
 
Thread Tools Display Modes
  #1  
Old May 22nd, 2009, 02:20 AM posted to microsoft.public.excel.worksheet.functions
chris
external usenet poster
 
Posts: 2,039
Default Function isn't recalculating

Hi guys, I have a function running in my workbook and it won't recalculate
automatically. I have an idea this is because it's being used 365 times on
one sheet. Is there any way to make this update automatically or do I need
to redesign this thing again?
  #2  
Old May 22nd, 2009, 03:13 AM posted to microsoft.public.excel.worksheet.functions
chris
external usenet poster
 
Posts: 2,039
Default Function isn't recalculating

I've tried using Application.Volatile and I've made sure that updates are set
to automatic already.. Is there a way to turn the following UDF into a normal
function?

Function SalesTotal() As Integer
Application.Volatile
Dim varDate As Date
Dim c As Range
varDate = ActiveCell.Offset(-1).Value
SalesTotal = 0
LastRow = Sheet19.Cells(Rows.Count, "M").End(xlUp).Row
Set MyRange = Sheet19.Range("M1:M" & LastRow)
For Each c In MyRange
If c.Value = varDate Then
SalesTotal = (SalesTotal + c.Offset(, 2).Value)
End If
Next
If IsError(SalesTotal) Then SalesTotal = 0
End Function

"Chris" wrote:

Hi guys, I have a function running in my workbook and it won't recalculate
automatically. I have an idea this is because it's being used 365 times on
one sheet. Is there any way to make this update automatically or do I need
to redesign this thing again?

  #3  
Old May 22nd, 2009, 09:06 AM posted to microsoft.public.excel.worksheet.functions
Rick Rothstein[_2_]
external usenet poster
 
Posts: 2,013
Default Function isn't recalculating

varDate = ActiveCell.Offset(-1).Value

I think your problem is in your use of ActiveCell... that may not be
pointing to what you think it is point to. I'm guessing you want to
reference the cell above the cell the UDF is in... if that is correct, then
try replacing the above line from your code with this line...

varDate = Application.Caller.Offset(-1).Value

--
Rick (MVP - Excel)


"Chris" wrote in message
...
I've tried using Application.Volatile and I've made sure that updates are
set
to automatic already.. Is there a way to turn the following UDF into a
normal
function?

Function SalesTotal() As Integer
Application.Volatile
Dim varDate As Date
Dim c As Range
varDate = ActiveCell.Offset(-1).Value
SalesTotal = 0
LastRow = Sheet19.Cells(Rows.Count, "M").End(xlUp).Row
Set MyRange = Sheet19.Range("M1:M" & LastRow)
For Each c In MyRange
If c.Value = varDate Then
SalesTotal = (SalesTotal + c.Offset(, 2).Value)
End If
Next
If IsError(SalesTotal) Then SalesTotal = 0
End Function

"Chris" wrote:

Hi guys, I have a function running in my workbook and it won't
recalculate
automatically. I have an idea this is because it's being used 365 times
on
one sheet. Is there any way to make this update automatically or do I
need
to redesign this thing again?


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:05 PM.


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