patrickdrd,
Try my sample code:
Private Sub Command1_Click()
With MSHFlexGrid1
.TextMatrix(1, 1) = 2
.TextMatrix(1, 2) = 3
.TextMatrix(1, 3) = 2
.TextMatrix(1, 4) = 2
.TextMatrix(2, 2) = 5
.TextMatrix(2, 3) = 5
.TextMatrix(2, 4) = 7
.TextMatrix(2, 5) = 5
.TextMatrix(2, 6) = 5
.TextMatrix(2, 7) = 5
.TextMatrix(3, 1) = 6
.TextMatrix(3, 3) = 6
.TextMatrix(3, 4) = 6
.TextMatrix(3, 5) = 6
.TextMatrix(3, 6) = 5
.TextMatrix(3, 7) = 5
.MergeCells = flexMergeFree
.MergeRow(1) = True
.MergeRow(2) = True
.MergeRow(3) = True
End With
End Sub
Private Sub Command2_Click()
Dim icol As Integer
Dim irow As Integer
Dim iSubTotal As Integer
Dim blnEven As Boolean
With MSHFlexGrid1
For irow = 1 To .Rows - 1
blnEven = True
For icol = 1 To .Cols - 2
If .MergeRow(irow) = True Then
If Val(.TextMatrix(irow, icol)) = Val(.TextMatrix(irow, icol + 1)) Then
If blnEven Then
iSubTotal = iSubTotal + Val(.TextMatrix(irow, icol)) + _
Val(.TextMatrix(irow, icol + 1))
Else
iSubTotal = iSubTotal + Val(.TextMatrix(irow, icol))
End If
blnEven = Not blnEven
End If
End If
Next icol
Next irow
End With
MsgBox iSubTotal
End Sub
Private Sub Form_Load()
MSHFlexGrid1.MergeCells = flexMergeFree
End Sub
Vladk