Compare two columns
"Bob I" wrote:
Columns are going down the sheet, are you sure you don't mean comparing
rows?
pm wrote:
I've got two columns that I'm trying to compare. If the 2nd column equals
the first then I want to cut the 2nd column and paste it into another column.
CK34041R IC 1
CK38711U IC 1
CMP-AS04S-SINGL SINGLE SPEAKER 1
CK38711U IC 0
CMP-AS04S-SINGL SINGLE SPEAKER 1
CMP-AS14 SPEAKER SET 1
Thanks.
Here's a macro I copied from another spreadsheet.....I was trying to modify it
Sub CheckInvNos()
' Macro recorded 5/9/2007 by Pam Michalk
'Enter starting column and heading row for the bottom section which will
have rows cut
sCheckCol = "G"
nCheckRow = 15772
'Enter the starting column and heading row for the top section which
will be compared
sCompareCol = "A"
nCompareStart = 1
nCompareRow = nCompareStart
sCompare = sCompareCol & nCompareRow
bContinue = True
Do While bContinue
nCheckRow = nCheckRow + 1
sCheck = sCheckCol & nCheckRow
Range(sCheck).Select
sInvNo = Selection.Value
nCompareRow = nCompareStart
If IsEmpty(sInvNo) Then
bContinue = False
Else
bCompare = True
Do While bCompare
nCompareRow = nCompareRow + 1
sCompare = sCompareCol & nCompareRow
Range(sCompare).Select
sCompInvNo = Selection.Value
If sInvNo = sCompInvNo Then
Range(sCheck).Select
Selection.EntireRow.Cut
Sheets("Sheet3").Select
ActiveSheet.Paste
nCheckRow = nCheckRow + 1
bCompare = False
ElseIf IsEmpty(sCompInvNo) Then
bCompare = False
End If
Loop
End If
Loop
End Sub
Thanks.
|