goodpasture said:
I guess nevermind on that last post about the match. The IFCOUN
actualyl seems to work but something further I think I'm going to nee
is that I need to be able to sort them so the matches are together.
should have a group where A and B are together (matched) and then
group where there is only stuff in A and then only stuff in B. thinkin
about it, is there maybe a way to just find out what's matching and ge
rid of it and then what should be left is stuff only in A and teh
stuff only in B.
Hi goodpasture
Try this macro it sorts the data to align the matches in the 2 columns
it assumes that Row 1 is a Header row so leaves that row alone, you
data should therefore start in row 2, it also assumes data is i
columns A and B
Option Explicit
Sub testme()
Application.ScreenUpdating = False
Dim wks As Worksheet
Dim ColA As Range
Dim ColB As Range
Dim iRow As Long
Dim myCols As Long
Set wks = Worksheets("sheet1")
wks.DisplayPageBreaks = False
With wks
'row 1 has headers!
Set ColA = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
Set ColB = .Range("b2", .Cells(.Rows.Count, "B").End(xlUp))
With ColA
.Sort key1:=.Cells(1), order1:=xlAscending, header:=xlNo
End With
'change the mycols to the number of columns that
'are associated with column B
myCols = 1 ' columns B only
With ColB.Resize(, myCols)
.Sort key1:=.Cells(1), order1:=xlAscending, header:=xlNo
End With
iRow = 2
Do
If Application.CountA(.Cells(iRow, "A").Resize(1, 2)) = 0 Then
Exit Do
End If
If .Cells(iRow, "A").Value = .Cells(iRow, "B").Value _
Or Application.CountA(.Cells(iRow, "A").Resize(1, 2)) = 1 Then
'do nothing
Else
If .Cells(iRow, "A").Value > .Cells(iRow, "B").Value Then
.Cells(iRow, "A").Insert shift:=xlDown
Else
.Cells(iRow, "B").Resize(1, myCols).Insert shift:=xlDown
End If
End If
iRow = iRow + 1
Loop
End With
Application.ScreenUpdating = True
End Su