Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Comparing values in 2 columns - Help needed


Hi There

Since I am quite new to Excel I am having some problems with comparing
values listet in two columns.
I need to compare the values in column B (lets say B1-B88) with the
values in A (A1 to A88). If the value in B1 (and so on) match any value
in A1-A88 it must be deleted from both columns(want to avoid double
count - some of the values may be listed more than once).
It sounds like a simple problem but I cant make it work.
I hope someone is able to help...Thanks :)

All the best

Tilde


--
tilde
------------------------------------------------------------------------
tilde's Profile: http://www.excelforum.com/member.php...o&userid=24424
View this thread: http://www.excelforum.com/showthread...hreadid=380264

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Comparing values in 2 columns - Help needed


Backup your workbook before trying this macro

try this macro and let me know

Sub macro()
Dim r, c As Range
Dim i, k As Variant
Range("b1:b88").Select
Set r = Selection
k = 88
For i = 1 To 88
If Range("b" & i).Value < "" Then
temp = check_value(Range("b" & i).Value)

If temp = 1 Then
Range("b" & i).Select
Selection.Delete Shift:=xlUp
i = i - 1
k = k - 1
Else

End If
End If
Next

End Sub

Function check_value(val As Variant)
Range("a1").Select
Range("a1:a88").Select
On Error Resume Next
Selection.Find(What:=val, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
Range(ActiveCell.Address).Select
Selection.Delete Shift:=xlUp
If Err.Description < "" Then
check_value = 0
Else
check_value = 1
End If
End Function


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=380264

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Comparing values in 2 columns - Help needed


Thanks for your answer.....It gives me something to work with. It doesnt
work properly but I will used your code and work on it :)



anilsolipuram Wrote:
Backup your workbook before trying this macro

try this macro and let me know

Sub macro()
Dim r, c As Range
Dim i, k As Variant
Range("b1:b88").Select
Set r = Selection
k = 88
For i = 1 To 88
If Range("b" & i).Value < "" Then
temp = check_value(Range("b" & i).Value)

If temp = 1 Then
Range("b" & i).Select
Selection.Delete Shift:=xlUp
i = i - 1
k = k - 1
Else

End If
End If
Next

End Sub

Function check_value(val As Variant)
Range("a1").Select
Range("a1:a88").Select
On Error Resume Next
Selection.Find(What:=val, After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
Range(ActiveCell.Address).Select
Selection.Delete Shift:=xlUp
If Err.Description < "" Then
check_value = 0
Else
check_value = 1
End If
End Function



--
tilde
------------------------------------------------------------------------
tilde's Profile: http://www.excelforum.com/member.php...o&userid=24424
View this thread: http://www.excelforum.com/showthread...hreadid=380264

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Comparing values in 2 columns - Help needed

Not sure this approach meets your needs, but this places a 1 in the third
column when the value in column B is found in column A.
The 1 can then be used to remove the duplicate entry (method not shonw).
But I am not sure about your requirement "deleted from both columns" - if
the objective is to remove entries from column A as duplicates also
appearing in column B, why do you want to remove column B entries as surely
this is the reference list that determines what to detect in A? Maybe I am
missing something(?).

Sub DeDupe()
Dim x As Long, y As Long, v As Variant
For x = 1 To 10
For y = 1 To 10
If Cells(x, 2) = Cells(y, 1) Then Cells(y, 3) = 1
Next y
Next x
End Sub

--
Cheers
Nigel



"tilde" wrote in
message ...

Hi There

Since I am quite new to Excel I am having some problems with comparing
values listet in two columns.
I need to compare the values in column B (lets say B1-B88) with the
values in A (A1 to A88). If the value in B1 (and so on) match any value
in A1-A88 it must be deleted from both columns(want to avoid double
count - some of the values may be listed more than once).
It sounds like a simple problem but I cant make it work.
I hope someone is able to help...Thanks :)

All the best

Tilde


--
tilde
------------------------------------------------------------------------
tilde's Profile:

http://www.excelforum.com/member.php...o&userid=24424
View this thread: http://www.excelforum.com/showthread...hreadid=380264



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
Comparing values in two columns P.hamsa Excel Discussion (Misc queries) 4 May 13th 07 04:50 PM
Comparing values in columns Sandy Excel Worksheet Functions 2 April 19th 07 09:40 AM
Macro Help Needed: Comparing cell values and deleting rows [email protected] Excel Discussion (Misc queries) 1 September 19th 06 02:39 AM
Comparing values in two columns and displaying missing values in n cpetta Excel Programming 1 April 2nd 05 06:18 AM
Comparing values in two columns nicoll Excel Programming 3 April 11th 04 03:17 PM


All times are GMT +1. The time now is 05:10 PM.

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"