Allen ik heb een klein functie waar ik niet helemaal uit kom. De bedoeling is dat voor een telling gemaakt moet worden van het aantal regels voor een bepaalde kolom (The_Col) waarvoor geldt dat die kolom de hoogste datum bevat.
Dus voor Kolom A is de uitkomst 2
Dus voor Kolom B is de uitkomst 1
Dus voor Kolom C is de uitkomst 0
Nu is het aantal kolommen 30 en aantal regels ongeveer 300. en simpele if-then-else constructies werken niet meer.
Ik heb onderstaande code gebrabbeld (niet veel ervaring in VB); en ik snap niet helemaal waar ik de mist in ga. Kunnen jullie mij verder helpen?
Alvast Bedankt!
| A | B | C | |
| 1 | 1-feb | 1-jan | |
| 2 | 2-jan | 2-feb | 1-jan |
| 3 | 3-mrt | 1-jan |
Dus voor Kolom A is de uitkomst 2
Dus voor Kolom B is de uitkomst 1
Dus voor Kolom C is de uitkomst 0
Nu is het aantal kolommen 30 en aantal regels ongeveer 300. en simpele if-then-else constructies werken niet meer.
Ik heb onderstaande code gebrabbeld (niet veel ervaring in VB); en ik snap niet helemaal waar ik de mist in ga. Kunnen jullie mij verder helpen?
Alvast Bedankt!
Visual Basic:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| Function CompareDates(The_Col As Integer, _ ColStart As Integer, ColEnd As Integer, _ RowStart As Integer, RowEnd As Integer) 'Compares For each row of The_Col weither it is the highest date of all Cols or not. 'Returns number of rows where it is the highest Dim c, r, count, bol, d1, d2 For r = RowStart To RowEnd bol = True For c = ColStart To ColEnd If (c <> The_Col) Then d1 = ActiveSheet.Cells(The_Col, r) d2 = ActiveSheet.Cells(c, r) bol = (bol & (d1 > d2)) Else End If Next c If bol Then count = count + 1 Else End If Next r CompareDates = count End Function |