Forrás: http://www.ozgrid.com/VBA/sum-multi-criteria.htm
Function SumByCriteria(Sum_Range As Range, Criteria1, Criteria1Range As Range, _
Criteria2, Criteria2Range As Range, Optional Criteria3, _
Optional Criteria3Range As Range, Optional Criteria4, _
Optional Criteria4Range As Range, Optional Criteria5, _
Optional Criteria5Range As Range) As Long
Dim lLoopStop As Long, lLoop As Long, rRange As Range, lRow As Long
Dim sTotal As Single, bVal1 As Boolean, bVal2 As Boolean, bVal3 As Boolean
Dim bVal4 As Boolean, bVal5 As Boolean, bVal1b As Boolean, bVal2b As Boolean, bVal3b As Boolean
Dim bVal4b As Boolean, bVal5b As Boolean, lCriteriaUsed As Long
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''Written by ozgrid.com''''''''''''''''''''''''''''''''''''''
'Sums Values in Sum_Range when up to 5 conditions are met in corresponding cells.
'All ranges used should as small as possible for efficieny
''IF YOU HAVE 2007 USE SUMIFS
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
lLoopStop = WorksheetFunction.CountIf(Criteria1Range, Criteria1)
bVal3 = Not Criteria3Range Is Nothing
bVal4 = Not Criteria4Range Is Nothing
bVal5 = Not Criteria5Range Is Nothing
If bVal5 = False Then lCriteriaUsed = 4
If bVal4 = False Then lCriteriaUsed = 3
If bVal3 = False Then lCriteriaUsed = 2
Set rRange = Criteria1Range(1, 1)
For lLoop = 1 To lLoopStop
Set rRange = Criteria1Range.Find(Criteria1, rRange, _
xlFormulas, xlWhole, xlByRows, xlNext, False)
lRow = rRange.Row
If bVal5 = True Then bVal5b = Criteria5Range(lRow, 1) = Criteria5
If bVal4 = True Then bVal4b = Criteria4Range(lRow, 1) = Criteria4
If bVal3 = True Then bVal3b = Criteria3Range(lRow, 1) = Criteria3
bVal2b = Criteria2Range(lRow, 1) = Criteria2
bVal1b = Criteria1Range(lRow, 1) = Criteria1
If lCriteriaUsed > 4 Then
If bVal5b And bVal4b And bVal3b And bVal2 And bVal1b Then
sTotal = WorksheetFunction.Sum(Sum_Range(lRow, 1), sTotal)
End If
ElseIf lCriteriaUsed > 3 Then
If bVal4b And bVal3b And bVal2b And bVal1b Then
sTotal = WorksheetFunction.Sum(Sum_Range(lRow, 1), sTotal)
End If
ElseIf lCriteriaUsed > 2 Then
If bVal3b And bVal2 And bVal1b Then
sTotal = WorksheetFunction.Sum(Sum_Range(lRow, 1), sTotal)
End If
ElseIf bVal2b And bVal1b Then
sTotal = WorksheetFunction.Sum(Sum_Range(lRow, 1), sTotal)
End If
Next lLoop
SumByCriteria = sTotal
End Function
Example usage;
=SumByCriteria(A1:A21,"cat",C1:C21,"furry",E1:E21,"fluffy",G1:G21,"persian",I1:I21)
2009. szeptember 30., szerda
2009. szeptember 21., hétfő
Excel: dupla kattintás letiltása
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Application.EditDirectlyInCell = True
Range("A1").Activate
Cancel = True 'Cancel the default behaviour
End Sub
Forrás:
http://www.thecodecage.com/forumz/excel-vba-programming/91029-disable-cursor-when-double-click.html
Application.EditDirectlyInCell = True
Range("A1").Activate
Cancel = True 'Cancel the default behaviour
End Sub
Forrás:
http://www.thecodecage.com/forumz/excel-vba-programming/91029-disable-cursor-when-double-click.html
2009. szeptember 7., hétfő
php Call to undefined function mssql_connect() hiba kezelése
PHP script parancssorból nem éri el az mssql adatbázist.
Megoldás:
apt-get update
apt-cache search php | grep "MS SQL"
A következő modult kell feltenni:
php5-sybase - Sybase / MS SQL Server module for php5
apt-get install php5-sybase
Apache reload:
/etc/init.d/apache2 reload
Megoldás:
apt-get update
apt-cache search php | grep "MS SQL"
A következő modult kell feltenni:
php5-sybase - Sybase / MS SQL Server module for php5
apt-get install php5-sybase
Apache reload:
/etc/init.d/apache2 reload
Feliratkozás:
Bejegyzések (Atom)