#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default SUMIF

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

Thanks.


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

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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default SUMIF

For SUMIF Formula, I found the following code posted some time ago by JE
McGimpsey helpful:

Dim n As Long
n = Application.WorksheetFunction.SumIf(Columns("A"), "<" & _
"Large Balance", Columns("B"))
MsgBox n



"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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default SUMIF

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.





  #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.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default SUMIF

when I run this CheckSession ( i.e put this formula in one of the field as
=CheckSession(N6.O6.P6,Q6,R6, N1,O1,P1,Q1,R1)), then I will get following
pop up message:

Microsoft Office Excel cannot calculate a formula. There is a circular
reference in an open workbook, but the references that cause it cannot be
listed for you. Try editing the last formula you entered or removing it with
the Undo command (Edit menu)

in the example below, if I replace C1-C5 with a Constant value, instead of
Application.WorksheetFunction.SumIf, then it will be OK.

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"))


Please advise, why calculating Application.WorksheetFunction.SumIf will
trigger circular references ?

Magix.


"MDW" wrote in message
...
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.








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
SUMIF Chi Excel Discussion (Misc queries) 3 March 16th 09 09:33 PM
sumif for multi conditions. i.e sumif(A1:A10,"Jon" and B1:B10,"A" Harry Seymour Excel Worksheet Functions 9 June 12th 07 10:47 PM
Embedding a Sumif in a sumif C.Pflugrath Excel Worksheet Functions 5 August 31st 05 07:31 PM
nested sumif or sumif with two criteria dshigley Excel Worksheet Functions 5 April 5th 05 03:34 AM
SUMIF - Range name to used for the "sum_range" portion of a SUMIF function Oscar Excel Worksheet Functions 2 January 11th 05 11:01 PM


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