Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default I must be tired, because basic Math isn't working.....

Sorry for cross post, initial post was probably wrong group...

Cell D3 = value
Cell D4 = value D3
Range C3:C20 and B3:B20 have values in them
Can someone tell me why the Case 1 gives back a #Value!

Thanks in advance - Marston

Function FIFO(Current, Prior, Source As Range,Compare As Range)
Dim A As Integer, B As Integer, C As Integer
Dim rng1 As Range, rng2 As Range
Set rng1 = Source
Set rng2 = Compare
A = Application.WorksheetFunction.Match(Current,Source ,1)
B = Application.WorksheetFunction.Match(Prior,Source,1 )
C = A - B
Select Case C
Case 0
FIFO = rng2.Offset(A,0)
Case 1
E = rng1.Offset(A-1,0)
F = rng2.Offset(A,0)
G = rng2.Offset(B,0)
FIFO = ((Current - E)*F +(E - Prior)*G)/(Current - Prior)
Case Else
FIFO = 0
End Select
End Function

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default I must be tired, because basic Math isn't working.....

Could you provide some data for Current, Prior, Source, and Compare. Without
knowing what the function is looking at it's hard to determine the problem.

Mike

" wrote:

Sorry for cross post, initial post was probably wrong group...

Cell D3 = value
Cell D4 = value D3
Range C3:C20 and B3:B20 have values in them
Can someone tell me why the Case 1 gives back a #Value!

Thanks in advance - Marston

Function FIFO(Current, Prior, Source As Range,Compare As Range)
Dim A As Integer, B As Integer, C As Integer
Dim rng1 As Range, rng2 As Range
Set rng1 = Source
Set rng2 = Compare
A = Application.WorksheetFunction.Match(Current,Source ,1)
B = Application.WorksheetFunction.Match(Prior,Source,1 )
C = A - B
Select Case C
Case 0
FIFO = rng2.Offset(A,0)
Case 1
E = rng1.Offset(A-1,0)
F = rng2.Offset(A,0)
G = rng2.Offset(B,0)
FIFO = ((Current - E)*F +(E - Prior)*G)/(Current - Prior)
Case Else
FIFO = 0
End Select
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
Math Functions Not Working Properly Harby Excel Worksheet Functions 3 April 21st 09 06:17 PM
math formulaes arent working in excel Russ Johnson Excel Worksheet Functions 3 May 2nd 08 09:27 PM
Excel n00b, how to do basic math functions Omohundro Excel Worksheet Functions 7 October 29th 07 07:39 PM
Excel can't do basic math?! Steven Sinclair Excel Discussion (Misc queries) 18 August 21st 06 09:42 PM
I must be tired, because basic Math isn't working..... [email protected] Excel Worksheet Functions 0 June 22nd 06 05:30 AM


All times are GMT +1. The time now is 09:08 PM.

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"