Thread: SUMIF
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default SUMIF

I don't see anything in the code you posted that looks like a circular
reference. Is it possible there is another function on your spreadsheet
that's causing the error?

You can suppress the error message by enabling Iteration on Excel. You can
do it manually by going to Tools - Options, and checking the "Iteration"
checkbox. You can also turn it on programmatically with the command
Application.Iteration = True. In most cases, this will make the error "go
away", but it won't fix the underlying problem if there is one.

--
Hmm...they have the Internet on COMPUTERS now!


"magix" wrote:

The excel always complaint about circular references. how can i prevent that
?

I need the value of SUMIF from C1 - C5, in order to compare with R1-R5

My code is as below:


Function CheckSession(S1 As String, S2 As String, S3 As String, S4 As
String, S5 As String, R1 As Integer, R2 As Integer, R3 As Integer, R4 As
Integer, R5 As Integer) As String


Dim Session As String
Dim C1 As Integer
Dim C2 As Integer
Dim C3 As Integer
Dim C4 As Integer
Dim C5 As Integer

C1 = Application.WorksheetFunction.SumIf(Range("AL5:AL3 807"), "1",
Range("AP5:AP3807"))
C2 = Application.WorksheetFunction.SumIf(Range("AL5:AL3 807"), "2",
Range("AP5:AP3807"))
C3 = Application.WorksheetFunction.SumIf(Range("AL5:AL3 807"), "3",
Range("AP5:AP3807"))
C4 = Application.WorksheetFunction.SumIf(Range("AL5:AL3 807"), "4",
Range("AP5:AP3807"))
C5 = Application.WorksheetFunction.SumIf(Range("AL5:AL3 807"), "5",
Range("AP5:AP3807"))


Session = ""

If ((S1 < "CLOSED") And (S1 < "N/A")) Then
If C1 < R1 Then
Session = S1
End If
End If
If ((S2 < "CLOSED") And (S2 < "N/A")) Then
If C2 < R2 Then
If Session = "" Then
Session = S2
Else
If Val(Session) Val(S2) Then
Session = S2
End If
End If
End If
End If

CheckSession = Session
End Function






"MDW" wrote in message
...
dblAnswer =
Application.WorksheetFunction.SumIf(LookInRange,Lo okForValue,SumRange)

--
Hmm...they have the Internet on COMPUTERS now!


"magix" wrote:

How can I integrate SUMIF excel formula into a visual basic function code
?
I'm trying to solve an circular reference issue.

Thanks.