hello!
I've been trying to resolve this but I can't finish it!
I have two workbooks, "Guides.xls" (workbook 1) and "Provider Guides.xls" (workbook 2). They have a lot of information but I only care the column with the numbers of guides and they can be in any column in the workbooks.
Is assumed that the numbers of guides are the same but we really don't know... So what I have to do is a macro that compare those columns and if there are more guides in any workbook, put them in another workbook.
I was working with this code but is not exactly what I need
Sub test()
Dim a, i As Long, b(), n As Long, x
a = Range("a1").CurrentRegion.Resize(,2).Value
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare
For i = 1 To UBound(a,1)
If (Not IsEmpty(a(i,1))) * (Not .exists(a(i,1))) Then .add a(i,1), Nothing
Next
ReDim b(1 To UBound(a,1), 1 To 1)
For i = 1 To UBound(a,1)
If Not IsEmpty(a(i,2)) Then
If Not .exists(a(i,2)) Then
n = n + 1 : b(n,1) = a(i,2)
Else
.remove a(i,2)
End If
End If
Next
x = .keys
End With
With Range("d1")
.CurrentRegion.ClearContents
.Resize(,2).Value = [{"Not in A", "No in B"}]
With .Offset(1)
If n > 0 Then .Resize.Value = b
End With
On Error Resume Next
.Offset(1,1).Resize(.Count).Value = Application.Transpose(x)
End With
End Sub
I would be really gateful for your help.
I've been trying to resolve this but I can't finish it!
I have two workbooks, "Guides.xls" (workbook 1) and "Provider Guides.xls" (workbook 2). They have a lot of information but I only care the column with the numbers of guides and they can be in any column in the workbooks.
Is assumed that the numbers of guides are the same but we really don't know... So what I have to do is a macro that compare those columns and if there are more guides in any workbook, put them in another workbook.
I was working with this code but is not exactly what I need
Sub test()
Dim a, i As Long, b(), n As Long, x
a = Range("a1").CurrentRegion.Resize(,2).Value
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare
For i = 1 To UBound(a,1)
If (Not IsEmpty(a(i,1))) * (Not .exists(a(i,1))) Then .add a(i,1), Nothing
Next
ReDim b(1 To UBound(a,1), 1 To 1)
For i = 1 To UBound(a,1)
If Not IsEmpty(a(i,2)) Then
If Not .exists(a(i,2)) Then
n = n + 1 : b(n,1) = a(i,2)
Else
.remove a(i,2)
End If
End If
Next
x = .keys
End With
With Range("d1")
.CurrentRegion.ClearContents
.Resize(,2).Value = [{"Not in A", "No in B"}]
With .Offset(1)
If n > 0 Then .Resize.Value = b
End With
On Error Resume Next
.Offset(1,1).Resize(.Count).Value = Application.Transpose(x)
End With
End Sub
I would be really gateful for your help.
Last edited: