VB6 - Transfer 1 grid to another

Hi

In my project example in attachment, i'm trying to transfer from one grid to the other by following this rule.

If Grid 1 column 0 > NULL, transfer specific cells into Grid 2.
If Grid 2 column 0 =  NULL, accept the data from Grid 1.

I'm using this below code so far but it just transfer 1 row.

How can i fix this.

Thanks

Private Sub transfer_Click()
   Dim i As Integer
    Dim a As Integer


    'HEADING FOR GRID
    MSHFlexGrid2.Clear
    MSHFlexGrid2.Rows = 2
    MSHFlexGrid2.Cols = 5

    '**********************   RATES   ***************************************

    For a = 1 To MSHFlexGrid2.Rows - 1
        For i = 0 To MSHFlexGrid1.Rows - 1
            If MSHFlexGrid2.TextMatrix(a, 0) = "" Then
                If MSHFlexGrid1.TextMatrix(i, 0) <> "" Then
                    MSHFlexGrid2.TextMatrix(a, 1) = MSHFlexGrid1.TextMatrix(i, 0)  '
                    MSHFlexGrid2.TextMatrix(a, 2) = MSHFlexGrid1.TextMatrix(i, 1)  '
                    MSHFlexGrid2.TextMatrix(a, 3) = MSHFlexGrid1.TextMatrix(i, 2)  '
                    MSHFlexGrid2.TextMatrix(a, 4) = MSHFlexGrid1.TextMatrix(i, 3)  '
                    MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
                End If

            End If
        Next
    Next

End Sub

Open in new window

Form1.zip
LVL 11
Wilder1626Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wilder1626Author Commented:
I think i found it

    Dim i As Integer
    Dim a As Integer


    'HEADING FOR GRID
    MSHFlexGrid2.Clear
    MSHFlexGrid2.Rows = 2
    MSHFlexGrid2.Cols = 5


    For i = 1 To MSHFlexGrid1.Rows - 1
        If MSHFlexGrid1.TextMatrix(i, 1) <> "" Then
            For a = 1 To MSHFlexGrid2.Rows - 1
                If MSHFlexGrid2.TextMatrix(a, 1) = "" Then

                    MSHFlexGrid2.TextMatrix(a, 1) = MSHFlexGrid1.TextMatrix(i, 0)  '
                    MSHFlexGrid2.TextMatrix(a, 2) = MSHFlexGrid1.TextMatrix(i, 1)  '
                    MSHFlexGrid2.TextMatrix(a, 3) = MSHFlexGrid1.TextMatrix(i, 2)  '
                    MSHFlexGrid2.TextMatrix(a, 4) = MSHFlexGrid1.TextMatrix(i, 3)  '
                    MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1

                End If

            Next a
        End If
    Next i

Open in new window

0
Wilder1626Author Commented:
No, it does not work correctly.

I'm duplicating values with the code if i add more If statement like below.

  Dim i As Integer
    Dim a As Integer


    'HEADING FOR GRID
    MSHFlexGrid2.Clear
    MSHFlexGrid2.Rows = 2
    MSHFlexGrid2.Cols = 5


    For i = 1 To MSHFlexGrid1.Rows - 1

            For a = 1 To MSHFlexGrid2.Rows - 1



                If MSHFlexGrid1.TextMatrix(i, 0) = "A" Then
                    If MSHFlexGrid2.TextMatrix(a, 1) = "" Then
                        MSHFlexGrid2.TextMatrix(a, 1) = MSHFlexGrid1.TextMatrix(i, 0)  '
                        MSHFlexGrid2.TextMatrix(a, 2) = MSHFlexGrid1.TextMatrix(i, 1)  '
                        MSHFlexGrid2.TextMatrix(a, 3) = MSHFlexGrid1.TextMatrix(i, 2)  '
                        MSHFlexGrid2.TextMatrix(a, 4) = MSHFlexGrid1.TextMatrix(i, 3)  '
                    End If
                End If


                If MSHFlexGrid1.TextMatrix(i, 0) = "C" Then
                    If MSHFlexGrid2.TextMatrix(a, 1) = "" Then
                        MSHFlexGrid2.TextMatrix(a, 1) = MSHFlexGrid1.TextMatrix(i, 0)  '
                        MSHFlexGrid2.TextMatrix(a, 2) = MSHFlexGrid1.TextMatrix(i, 1)  '
                        MSHFlexGrid2.TextMatrix(a, 3) = MSHFlexGrid1.TextMatrix(i, 2)  '
                        MSHFlexGrid2.TextMatrix(a, 4) = MSHFlexGrid1.TextMatrix(i, 3)  ' '
                    End If
                End If

                MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
            Next a
    Next i

Open in new window

0
Wilder1626Author Commented:
I will try this way

    Dim i As Integer
    Dim a As Integer

    'HEADING FOR GRID
    MSHFlexGrid2.Clear
    MSHFlexGrid2.Rows = 2
    MSHFlexGrid2.Cols = 5


    For i = 1 To MSHFlexGrid1.Rows - 1


        If MSHFlexGrid1.TextMatrix(i, 0) = "D" Then
            For a = 1 To MSHFlexGrid2.Rows - 1
                If MSHFlexGrid2.TextMatrix(a, 1) = "" Then
                    MSHFlexGrid2.TextMatrix(a, 1) = MSHFlexGrid1.TextMatrix(i, 0)  '
                    MSHFlexGrid2.TextMatrix(a, 2) = MSHFlexGrid1.TextMatrix(i, 1)  '
                    MSHFlexGrid2.TextMatrix(a, 3) = MSHFlexGrid1.TextMatrix(i, 2)  '
                    MSHFlexGrid2.TextMatrix(a, 4) = MSHFlexGrid1.TextMatrix(i, 3)  ' '
                    MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
                End If
            Next a
        End If



        If MSHFlexGrid1.TextMatrix(i, 0) = "C" Then
            For a = 1 To MSHFlexGrid2.Rows - 1
                If MSHFlexGrid2.TextMatrix(a, 1) = "" Then
                    MSHFlexGrid2.TextMatrix(a, 1) = MSHFlexGrid1.TextMatrix(i, 0)  '
                    MSHFlexGrid2.TextMatrix(a, 2) = MSHFlexGrid1.TextMatrix(i, 1)  '
                    MSHFlexGrid2.TextMatrix(a, 3) = MSHFlexGrid1.TextMatrix(i, 2)  '
                    MSHFlexGrid2.TextMatrix(a, 4) = MSHFlexGrid1.TextMatrix(i, 3)  ' '
                    MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
                End If
            Next a
        End If

    Next i

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Martin LissOlder than dirtCommented:
I don't see how grid 2 can have anything in it so this just transfers the data from grid 1 to grid 2.

Private Sub transfer_Click()
    Dim i As Integer
    Dim a As Integer


    'HEADING FOR GRID
    MSHFlexGrid2.Clear
    MSHFlexGrid2.Rows = 1
    MSHFlexGrid2.Cols = 5

    For a = 0 To MSHFlexGrid1.Rows - 1
        If MSHFlexGrid2.TextMatrix(a, 0) = "" Then
            For i = 0 To MSHFlexGrid1.Rows - 1
                If MSHFlexGrid1.TextMatrix(i, 0) <> "" Then
                    If a > MSHFlexGrid2.Rows - 1 Then
                        MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
                    End If
                    MSHFlexGrid2.TextMatrix(a, 1) = MSHFlexGrid1.TextMatrix(i, 0)  '
                    MSHFlexGrid2.TextMatrix(a, 2) = MSHFlexGrid1.TextMatrix(i, 1)  '
                    MSHFlexGrid2.TextMatrix(a, 3) = MSHFlexGrid1.TextMatrix(i, 2)  '
                    MSHFlexGrid2.TextMatrix(a, 4) = MSHFlexGrid1.TextMatrix(i, 3)  '
                    a = a + 1
                End If
            Next i
        End If
    Next a

End Sub

Open in new window

0
Martin LissOlder than dirtCommented:
This considers that there might already be data in grid 2. Please note lines 10 - 12.

Private Sub transfer_Click()
    Dim lngGrid1Row As Long
    Dim lngGrid2Row As Long


    On Error GoTo ErrorRoutine
    
    'HEADING FOR GRID
    'MSHFlexGrid2.Clear
    'NOTE: If MSHFlexGrid2 can have data in it already you don't
    '      want to do this.
    MSHFlexGrid2.Rows = 2
    
    MSHFlexGrid2.Cols = 5

    For lngGrid1Row = 0 To MSHFlexGrid1.Rows - 1
        If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0) <> "" Then
            If MSHFlexGrid2.TextMatrix(lngGrid1Row, 0) = "" Then
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 0)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 2) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 1)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 3) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 2)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 4) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 3)  '
            Else
                lngGrid2Row = lngGrid2Row + 1
            End If
        End If
    Next
    Exit Sub
ErrorRoutine:
    MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
    lngGrid2Row = lngGrid2Row + 1
    Resume
End Sub

Open in new window

0
Wilder1626Author Commented:
Hi MartiLiss

I'M looking at your second post.

I may have something in my grid already.

So if i update the code like below, I see that it jump some rows when i would like to have them one under the others.

    Dim lngGrid1Row As Long
    Dim lngGrid2Row As Long
    
     MSHFlexGrid2.Rows = 2
    
    MSHFlexGrid2.Cols = 5



    On Error GoTo ErrorRoutine
    
    'HEADING FOR GRID
    'MSHFlexGrid2.Clear
    'NOTE: If MSHFlexGrid2 can have data in it already you don't
    '      want to do this.
   
    For lngGrid1Row = 0 To MSHFlexGrid1.Rows - 1
        If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0) = "A" Then
            If MSHFlexGrid2.TextMatrix(lngGrid1Row, 0) = "" Then
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 0)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 2) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 1)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 3) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 2)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 4) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 3)  '
            Else
                lngGrid2Row = lngGrid2Row + 1
            End If
        End If
        
        
         If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0) = "E" Then
            If MSHFlexGrid2.TextMatrix(lngGrid1Row, 0) = "" Then
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 0)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 2) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 1)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 3) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 2)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 4) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 3)  '
            Else
                lngGrid2Row = lngGrid2Row + 1
            End If
        End If
        
        
                 If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0) = "B" Then
            If MSHFlexGrid2.TextMatrix(lngGrid1Row, 0) = "" Then
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 0)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 2) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 1)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 3) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 2)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 4) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 3)  '
            Else
                lngGrid2Row = lngGrid2Row + 1
            End If
        End If
        
        
        
    Next
    Exit Sub
ErrorRoutine:
    MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
    lngGrid2Row = lngGrid2Row + 1
    Resume

Open in new window



Grid transfer
0
Wilder1626Author Commented:
Ok

let me put this another way.

If i have 2 button:

Botton 1:
 Dim lngGrid1Row As Long
    Dim lngGrid2Row As Long


    On Error GoTo ErrorRoutine
    
    For lngGrid1Row = 0 To MSHFlexGrid1.Rows - 1
        If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0)  =  "A" Then
            If MSHFlexGrid2.TextMatrix(lngGrid1Row, 0) = "" Then
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 0)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 2) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 1)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 3) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 2)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 4) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 3)  '
            Else
                lngGrid2Row = lngGrid2Row + 1
            End If
        End If
    Next
    Exit Sub
ErrorRoutine:
    MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
    lngGrid2Row = lngGrid2Row + 1
    Resume

Open in new window



Botton 2:
 Dim lngGrid1Row As Long
    Dim lngGrid2Row As Long


    On Error GoTo ErrorRoutine
    
    For lngGrid1Row = 0 To MSHFlexGrid1.Rows - 1
        If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0)  =  "E" Then
            If MSHFlexGrid2.TextMatrix(lngGrid1Row, 0) = "" Then
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 0)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 2) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 1)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 3) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 2)  '
                MSHFlexGrid2.TextMatrix(lngGrid2Row, 4) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 3)  '
            Else
                lngGrid2Row = lngGrid2Row + 1
            End If
        End If
    Next
    Exit Sub
ErrorRoutine:
    MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
    lngGrid2Row = lngGrid2Row + 1
    Resume

Open in new window


The result in MSHFlexgrid 2 should be A and E rows only
0
Martin LissOlder than dirtCommented:
I carelessly coded the ErrorRoutine to add a new row whenever any error occurred. Try the following that adds a new row only when a new row needs to be added to grid 2.
ErrorRoutine:
    If Err.Number = 381 Then
        MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
        lngGrid2Row = lngGrid2Row + 1
        Resume
    Else
        MsgBox "Error " & Err.Number & " ignored"
    End If

Open in new window

I assume that you are getting some other error that I don't get and that's what the "Else" is all about, and that part can be removed if you don't care about it.

BTW here's what I get after pre-loading "data" into row 1 of grid 2.
Works for me
0
Wilder1626Author Commented:
Sorry, I can't seem to make it work properly.

let me try again.
0
Martin LissOlder than dirtCommented:
Please attach your form again including the changes that I suggested.
0
Wilder1626Author Commented:
Ok.

Here is the project
Form1.zip
0
Martin LissOlder than dirtCommented:
Please describe for me exactly what results you expect when each of the 3 command buttons is clicked.
0
Wilder1626Author Commented:
Sure.

Each time i will click on one of the command it will add the data to the MSHFlexgrid2. If i click 2 time the same command, it will add 2 times the same data also.

Command 1 would transfer into grid 2 if column 0 = A
If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0) = "A" Then

Command 2 would transfer into grid 2 if column 0 = E
If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0) = "E" Then

Command 3 would transfer into grid 2 if column 0 = C
If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0) = "C" Then

If i click on command 1 and 3,  it will transfer into grid 2 if column 0 = A and C...
0
Martin LissOlder than dirtCommented:
Here's the code for the 3 buttons.
Private Sub transfer_Click()
    Dim lngGrid1Row As Long
    Dim lngGrid2Row As Long
    Dim bBlankRowFound As Boolean
    
    'MSHFlexGrid2.Rows = 2
    
    MSHFlexGrid2.Cols = 5

    For lngGrid1Row = 0 To MSHFlexGrid1.Rows - 1
        If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0) = "A" Then
            For lngGrid2Row = 1 To MSHFlexGrid2.Rows - 1
                If MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = "" Then
                    bBlankRowFound = True
                    Exit For
                End If
            Next
            If Not bBlankRowFound Then
                MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
                lngGrid2Row = MSHFlexGrid2.Rows - 1
            End If
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 0)
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 2) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 1)
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 3) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 2)
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 4) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 3)
            Exit For
        End If
    Next
 
End Sub

Private Sub Command_Click()
    Dim lngGrid1Row As Long
    Dim lngGrid2Row As Long
    Dim bBlankRowFound As Boolean
    
    'MSHFlexGrid2.Rows = 2
    
    MSHFlexGrid2.Cols = 5

    For lngGrid1Row = 0 To MSHFlexGrid1.Rows - 1
        If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0) = "E" Then
            For lngGrid2Row = 1 To MSHFlexGrid2.Rows - 1
                If MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = "" Then
                    bBlankRowFound = True
                    Exit For
                End If
            Next
            If Not bBlankRowFound Then
                MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
                lngGrid2Row = MSHFlexGrid2.Rows - 1
            End If
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 0)
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 2) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 1)
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 3) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 2)
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 4) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 3)
            Exit For
        End If
    Next
End Sub

Private Sub Command1_Click()
    Dim lngGrid1Row As Long
    Dim lngGrid2Row As Long
    Dim bBlankRowFound As Boolean
    
    'MSHFlexGrid2.Rows = 2
    
    MSHFlexGrid2.Cols = 5

    For lngGrid1Row = 0 To MSHFlexGrid1.Rows - 1
        If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0) = "C" Then
            For lngGrid2Row = 1 To MSHFlexGrid2.Rows - 1
                If MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = "" Then
                    bBlankRowFound = True
                    Exit For
                End If
            Next
            If Not bBlankRowFound Then
                MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
                lngGrid2Row = MSHFlexGrid2.Rows - 1
            End If
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 0)
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 2) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 1)
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 3) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 2)
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 4) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 3)
            Exit For
        End If
    Next
End Sub

Open in new window

0
Wilder1626Author Commented:
HI again

I think we are almost there.

Looks like if a have multiple time the same value in:  MSHFlexGrid1.TextMatrix(lngGrid1Row, 0) = "A", it does not transfer them. Only the first one.

If i have an A in 3 rows in the grid, it should transfer all 3 of them.

Same thing for all command.

Thanks again
0
Martin LissOlder than dirtCommented:
I hope this is it. In each of the 3 command buttons add line 11 and comment out line 27.
Private Sub transfer_Click()
    Dim lngGrid1Row As Long
    Dim lngGrid2Row As Long
    Dim bBlankRowFound As Boolean
    
    'MSHFlexGrid2.Rows = 2
    
    MSHFlexGrid2.Cols = 5

    For lngGrid1Row = 0 To MSHFlexGrid1.Rows - 1
        bBlankRowFound = False
        If MSHFlexGrid1.TextMatrix(lngGrid1Row, 0) = "A" Then
            For lngGrid2Row = 1 To MSHFlexGrid2.Rows - 1
                If MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = "" Then
                    bBlankRowFound = True
                    Exit For
                End If
            Next
            If Not bBlankRowFound Then
                MSHFlexGrid2.Rows = MSHFlexGrid2.Rows + 1
                lngGrid2Row = MSHFlexGrid2.Rows - 1
            End If
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 1) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 0)
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 2) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 1)
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 3) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 2)
            MSHFlexGrid2.TextMatrix(lngGrid2Row, 4) = MSHFlexGrid1.TextMatrix(lngGrid1Row, 3)
            'Exit For
        End If
    Next
 
End Sub

Open in new window


In your last post you said "If i have an A in..." and I should mention that the code only looks for "A" (in this code) and it would not transfer the data if were for example "Apple".
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Wilder1626Author Commented:
This is perfect.

Thank again for your patience and time. I really appreciate your help.
0
Martin LissOlder than dirtCommented:
You're welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.