I have this code bellow that transfer data from 1 grid to another.
The issue i have is with this part of the code:
For z = MSHFlexGrid2.Rows - 1 To 0 Step -1 For zz = 1 To MSHFlexGrid2.Rows - 1 If MSHFlexGrid4.TextMatrix(z, 0) = MSHFlexGrid2.TextMatrix(zz, 0) Then MSHFlexGrid4.TextMatrix(z, 2) = MSHFlexGrid2.TextMatrix(zz, 1) MSHFlexGrid4.Row = z MSHFlexGrid4.Col = 1 MSHFlexGrid4.CellBackColor = &H80FF& End If Next zz Next z
The Preferred carrier column from MSHFlexgrid4 should not have duplicate value. If it was transferred once, it should not show twice based on the DOOR letter.
Then, if for example, in grid 4, i only have 1 door B but in grid 2, i have 4 B door, then it should add a new row, add Door B in column 0 and add the value in column Preferred carrier column from MSHFlexgrid4.
How can i do that please?
Thanks again for your help
FULL CODE:
Dim i As Integer For i = 0 To MSHFlexGrid3.Rows - 1 If MSHFlexGrid3.TextMatrix(i, 0) <> "" Then MSHFlexGrid4.TextMatrix(i, 0) = MSHFlexGrid3.TextMatrix(i, 0) MSHFlexGrid4.TextMatrix(i, 1) = MSHFlexGrid3.TextMatrix(i, 1) MSHFlexGrid4.Rows = MSHFlexGrid4.Rows + 1 End If Next i 'Delete empty row Dim j As Integer Dim k As Integer Dim sSQL As String For k = MSHFlexGrid4.Rows - 1 To 1 Step -1 sSQL = "" For j = 1 To MSHFlexGrid4.Cols - 1 sSQL = sSQL & Trim(MSHFlexGrid4.TextMatrix(k, j)) Next If Trim(sSQL) = "" Then MSHFlexGrid4.RemoveItem k End If If MSHFlexGrid4.Rows <= 1 Then Exit For Next Dim z As Integer Dim zz As Integer MSHFlexGrid4.Cols = MSHFlexGrid4.Cols + 1 MSHFlexGrid4.TextMatrix(0, 2) = "Preferred Carrier" For z = MSHFlexGrid2.Rows - 1 To 0 Step -1 For zz = 1 To MSHFlexGrid2.Rows - 1 If MSHFlexGrid4.TextMatrix(z, 0) = MSHFlexGrid2.TextMatrix(zz, 0) Then MSHFlexGrid4.TextMatrix(z, 2) = MSHFlexGrid2.TextMatrix(zz, 1) MSHFlexGrid4.Row = z MSHFlexGrid4.Col = 1 MSHFlexGrid4.CellBackColor = &H80FF& End If Next zz Next z
If I understand it well you trying to do this
not repeating the preferred carrier but insert new lines when there are more than in order group.
Right?
Regards