Solved

VB6 - Transfer 1 grid to another

Posted on 2014-11-08
18
150 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
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 45

Expert Comment

by:Martin Liss
Comment Utility
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
Comment Utility
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
Comment Utility
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 45

Expert Comment

by:Martin Liss
Comment Utility
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
Comment Utility
Sorry, I can't seem to make it work properly.

let me try again.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 45

Expert Comment

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

Author Comment

by:Wilder1626
Comment Utility
Ok.

Here is the project
Form1.zip
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
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
Comment Utility
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 45

Expert Comment

by:Martin Liss
Comment Utility
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
Comment Utility
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 45

Accepted Solution

by:
Martin Liss earned 500 total points
Comment Utility
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
Comment Utility
This is perfect.

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

Expert Comment

by:Martin Liss
Comment Utility
You're welcome.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now