Results 1 to 9 of 9

Thread: [RESOLVED] find the elements that are not in both objects vb.net

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2021
    Posts
    39

    Resolved [RESOLVED] find the elements that are not in both objects vb.net

    Hello guys, im trying to loop over two collumns in two worksheets if an element is in both columns i sort it in a datagrid otherwise, if it's only in one (in the worksheet ws1) and it doesn't existe in the othe column i also wanna add it but don't know how, i will post part of my code maybe it will explain more.
    Code:
    Dim ws1 as excel.worksheet
    Dim ws2 as excel.worksheet
     ws1 = xlApp.Workbooks.Open(TextBox1.Text).Worksheets(ComboBox1.SelectedItem)
     ws2 = xlApp.Workbooks.Open(TextBox2.Text).Worksheets(ComboBox2.SelectedItem)
    
    Dim findme1 As Excel.Range = ws1.Range("A4:A" & Range1.Rows.Count)
    Dim findme2 As Excel.Range = ws2.Range("F5:F" & Range2.Rows.Count)
    Dim MyArray As Object(,) = CType(findme1.Value, Object(,))
    Dim MyArrayy As Object(,) = CType(findme2.Value, Object(,))
    
    
    For n = 1 To MyArray.Length
              For m = 1 To MyArrayy.Length
                    If MyArray(n, 1) = MyArrayy(m, 1) Then
                                        Form2.DataGridView1.Rows.Add(MyArray(n, 1), MyArrayy(m, 1), "Not OK")
                     End If
    
               Next
    Next
    i wanna add to the datagridview the ones that are just in findme1 and do not exist in findme2 thank you so much in advanced
    Last edited by highfly884; Sep 10th, 2021 at 05:10 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width