![]() |
SUMIF in Visual Basic Function
Can anyone translate the excel function SUMIF into Visual Basic Function
format ? |
SUMIF in Visual Basic Function
Dim var as Integer
var = 0 Do If MyCondition = True Then var = var + 1 Loop Debug.Print var 'MH "magix" wrote in message ... Can anyone translate the excel function SUMIF into Visual Basic Function format ? |
SUMIF in Visual Basic Function
The excel always complaint about circular references. how can i prevent that
? If I use Application.WorksheetFunction.SumIf: C1 = Application.WorksheetFunction.SumIf... then I will get the alert of Circular reference. Why ? and How to get rid of ? 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 "MH" wrote in message ... Dim var as Integer var = 0 Do If MyCondition = True Then var = var + 1 Loop Debug.Print var 'MH "magix" wrote in message ... Can anyone translate the excel function SUMIF into Visual Basic Function format ? |
SUMIF in Visual Basic Function
Sub DoItLikeSumIf() Dim dblAnswer As Double dblAnswer = Application.WorksheetFunction.SumIf(Range("B5:B10" ), _ "=Mush", Range("D5:D10")) MsgBox dblAnswer End Sub -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware "magix" wrote in message Can anyone translate the excel function SUMIF into Visual Basic Function format ? |
All times are GMT +1. The time now is 07:21 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com