#1   Report Post  
Posted to microsoft.public.excel.misc
pm pm is offline
external usenet poster
 
Posts: 122
Default Compare two columns

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.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,819
Default Compare two columns

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.


  #3   Report Post  
Posted to microsoft.public.excel.misc
pm pm is offline
external usenet poster
 
Posts: 122
Default Compare two columns

Hi Bob,

I actually have the data side by side in columns. I want to compare the two
and if there is a match, cut the 2nd column and paste it in a separate sheet.
Thanks.

"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.



  #4   Report Post  
Posted to microsoft.public.excel.misc
pm pm is offline
external usenet poster
 
Posts: 122
Default 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.
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,819
Default Compare two columns

This will compare cells in A with cells in B in rows 1 thru 20 and if
they all match cut B1:B20 from sheet 1 and insert into column A of Sheet2.


Sub Macro2()
'
' Macro2 Macro
'
'

Sheets("Sheet1").Select
y = 0
For x = 1 To 20
LCell = "A" & x
RCell = "B" & x
If Range(LCell) = Range(RCell) Then
y = y + 1
End If
Next x
If y = 20 Then
Range("B1:B20").Select
Selection.Cut
Sheets("Sheet2").Select
Range("A1:A20").Select
Selection.Insert Shift:=xlToRight
Sheets("Sheet1").Select
Range("A1:A20").Select
End If

End Sub


pm wrote:

Hi Bob,

I actually have the data side by side in columns. I want to compare the two
and if there is a match, cut the 2nd column and paste it in a separate sheet.
Thanks.

"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.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare 4 columns? Deb Excel Worksheet Functions 1 May 16th 06 09:14 AM
compare columns fluffy Excel Worksheet Functions 3 March 10th 06 03:59 PM
Compare Columns Michael Nesi Excel Discussion (Misc queries) 1 December 6th 04 08:45 PM
Compare two columns Need Helper Excel Discussion (Misc queries) 3 December 4th 04 03:08 AM


All times are GMT +1. The time now is 03:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"