Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Cell Updating with formulas

Hi,

I have created a sheet which calls the row() function and sends it to a USER
defined function. This function (WeekTotal) in turn processes the data in
the row. This all works as planned. However, I also have a 2nd copy of the
main sheet in the same workbook, but with different values in the row. What
is happening is when I calculate the fields in Sheet 1, it also sends these
values to Sheet 2 (so sheet 2 is wrong). If I am in sheet 2 and calculate
the fields, then the calculations are correct, but it also sends these
same values to sheet 1. So now sheet 1 is wrong. These need to be
independant of one another.

I can't figure out why it is sending values from one sheet to another, when

Function in Excel Cell
=WeekTotal(ROW())

---------------------------------------------------------
Function WeekTotal(rowNum As Integer) As Single

'Columns D-J contain the shift information
Dim total As Single
Dim iCount As Integer
Dim rangeLetter As String
Dim rangeCell As String

rangeLetter = "D"
total = 0

On Error Resume Next 'Ignore blank days or days not following the time
format
For iCount = 1 To 7
rangeCell = rangeLetter & rowNum
total = total + shiftLength(ActiveSheet.Range(rangeCell).Value)
rangeLetter = Chr$(Asc(rangeLetter) + 1)
Next
On Error GoTo 0

WeekTotal = total
End Function




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Cell Updating with formulas

Hi,

The problem seems to be that the function operates on values from the active sheet, which is not necessarily the same sheet where the function is entered.

Often cell references are passed to a function as parameters, and then there is no problem.

How to best solve your problem I don't know, but one way may be to use Application.Caller.Parent instead of ActiveSheet.

HTH
Anders Silvén

"boots" skrev i meddelandet news:aDPub.435088$6C4.357510@pd7tw1no...
Hi,

I have created a sheet which calls the row() function and sends it to a USER
defined function. This function (WeekTotal) in turn processes the data in
the row. This all works as planned. However, I also have a 2nd copy of the
main sheet in the same workbook, but with different values in the row. What
is happening is when I calculate the fields in Sheet 1, it also sends these
values to Sheet 2 (so sheet 2 is wrong). If I am in sheet 2 and calculate
the fields, then the calculations are correct, but it also sends these
same values to sheet 1. So now sheet 1 is wrong. These need to be
independant of one another.

I can't figure out why it is sending values from one sheet to another, when

Function in Excel Cell
=WeekTotal(ROW())

---------------------------------------------------------
Function WeekTotal(rowNum As Integer) As Single

'Columns D-J contain the shift information
Dim total As Single
Dim iCount As Integer
Dim rangeLetter As String
Dim rangeCell As String

rangeLetter = "D"
total = 0

On Error Resume Next 'Ignore blank days or days not following the time
format
For iCount = 1 To 7
rangeCell = rangeLetter & rowNum
total = total + shiftLength(ActiveSheet.Range(rangeCell).Value)
rangeLetter = Chr$(Asc(rangeLetter) + 1)
Next
On Error GoTo 0

WeekTotal = total
End Function




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Cell Updating with formulas

Thanks, that did the trick.

"Anders S" wrote in message
...
Hi,

The problem seems to be that the function operates on values from the active
sheet, which is not necessarily the same sheet where the function is
entered.

Often cell references are passed to a function as parameters, and then there
is no problem.

How to best solve your problem I don't know, but one way may be to use
Application.Caller.Parent instead of ActiveSheet.

HTH
Anders Silvén

"boots" skrev i meddelandet
news:aDPub.435088$6C4.357510@pd7tw1no...
Hi,

I have created a sheet which calls the row() function and sends it to a

USER
defined function. This function (WeekTotal) in turn processes the data in
the row. This all works as planned. However, I also have a 2nd copy of the
main sheet in the same workbook, but with different values in the row.

What
is happening is when I calculate the fields in Sheet 1, it also sends

these
values to Sheet 2 (so sheet 2 is wrong). If I am in sheet 2 and calculate
the fields, then the calculations are correct, but it also sends these
same values to sheet 1. So now sheet 1 is wrong. These need to be
independant of one another.

I can't figure out why it is sending values from one sheet to another,

when

Function in Excel Cell
=WeekTotal(ROW())

---------------------------------------------------------
Function WeekTotal(rowNum As Integer) As Single

'Columns D-J contain the shift information
Dim total As Single
Dim iCount As Integer
Dim rangeLetter As String
Dim rangeCell As String

rangeLetter = "D"
total = 0

On Error Resume Next 'Ignore blank days or days not following the time
format
For iCount = 1 To 7
rangeCell = rangeLetter & rowNum
total = total + shiftLength(ActiveSheet.Range(rangeCell).Value)
rangeLetter = Chr$(Asc(rangeLetter) + 1)
Next
On Error GoTo 0

WeekTotal = total
End Function






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
Formulas not updating T Excel Discussion (Misc queries) 9 October 29th 09 06:02 PM
Formulas updating Corinnak Excel Worksheet Functions 1 December 26th 07 05:58 PM
Formulas aren't updating ANTHER Excel Worksheet Functions 2 May 26th 07 06:36 PM
updating formulas with named cell references in a different worksh sjSQW Excel Worksheet Functions 0 May 21st 07 01:49 PM
Updating formulas craftcenter Excel Worksheet Functions 3 March 31st 06 12:50 AM


All times are GMT +1. The time now is 08:30 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"