Solved

VB6 - Transfer 1 grid to another

Posted on 2014-11-08
18
155 Views
Last Modified: 2014-11-10
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
0
Comment
Question by:Wilder1626
  • 10
  • 8
18 Comments
 
LVL 11

Author Comment

by:Wilder1626
ID: 40430228
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
 
LVL 11

Author Comment

by:Wilder1626
ID: 40430248
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
 
LVL 11

Author Comment

by:Wilder1626
ID: 40430283
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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 46

Expert Comment

by:Martin Liss
ID: 40430803
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
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40430830
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
 
LVL 11

Author Comment

by:Wilder1626
ID: 40431599
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
 
LVL 11

Author Comment

by:Wilder1626
ID: 40431604
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
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40431615
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
 
LVL 11

Author Comment

by:Wilder1626
ID: 40431643
Sorry, I can't seem to make it work properly.

let me try again.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40431658
Please attach your form again including the changes that I suggested.
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 40431703
Ok.

Here is the project
Form1.zip
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40431750
Please describe for me exactly what results you expect when each of the 3 command buttons is clicked.
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 40431846
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
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40431905
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
 
LVL 11

Author Comment

by:Wilder1626
ID: 40432589
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
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 40432808
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
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 40432841
This is perfect.

Thank again for your patience and time. I really appreciate your help.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40432871
You're welcome.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question