Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Matching cells

Col A has 200 cells (i.e., A1.A200)
Col B has 1500 cells (i.e., B1.B1500)

How can I find the cells in Col A whose contents match the contents in
the cells in Col B?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Matching cells

Hi Gary,

Easy enough to do but need more information on what you want to do when the
match is found.

Do you need to know if there is more than one match or if one match found is
that sufficient? (If one match is sufficient the VLOOKUP might so what you
want.)

What do you want to write against the cell where a match is found? (could
write the matching cell address/s if required.

Regards,

OssieMac

"gary" wrote:

Col A has 200 cells (i.e., A1.A200)
Col B has 1500 cells (i.e., B1.B1500)

How can I find the cells in Col A whose contents match the contents in
the cells in Col B?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 477
Default Matching cells

Use Conditional Formatting is one-way.
While in Call A1 (activecell) Go to Format, Condtional Formatting
Choose FormulaIs and in Box put =COUNTIF(B:B,A1)0
Use your Format Painter to Paint A1 to A2:A200

Jim May

"gary" wrote:

Col A has 200 cells (i.e., A1.A200)
Col B has 1500 cells (i.e., B1.B1500)

How can I find the cells in Col A whose contents match the contents in
the cells in Col B?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Matching cells


In Col A, the data occurs once
In Col B, the data may occur multiple times.

I need to know about ALL matches.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Matching cells

Hi again Gary,

The following macro will set the interior color of the cells in column A to
yellow if they are found in column B. It then inserts the address of the
column A value in column C adjacent to the found value (there could be
multiple occurrences of this address).

Sub Match_Values()

Dim rngA As Range
Dim rngB As Range
Dim CellA As Range
Dim foundCell As Range
Dim firstAddress As String

'Following assigns ranges of unknown length to
'variables starting from first cell of range.
With Sheets("Sheet1")
Set rngA = Range(.Cells(1, 1), _
.Cells(Rows.Count, 1).End(xlUp))
Set rngB = Range(.Cells(1, 2), _
.Cells(Rows.Count, 2).End(xlUp))
End With

'Alternative method of assigning ranges to a
'variable where the range is fixed and known.
'Set rngA = Sheets("Sheet1").Range("A1:A200")
'Set rngB = Sheets("Sheet1").Range("B1:B1500")

For Each CellA In rngA
With rngB
Set foundCell = .Find(What:=CellA, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)

If Not foundCell Is Nothing Then
firstAddress = foundCell.Address
Do
'Set interior color of found cell to yellow
CellA.Interior.ColorIndex = 6

'Insert cell address from column A
foundCell.Offset(0, 1) = CellA.Address

Set foundCell = .FindNext(foundCell)

Loop While Not foundCell Is Nothing And _
foundCell.Address < firstAddress
End If
End With
Next CellA
End Sub

Regards,

OssieMac

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
display a range of cells editible cells based on matching date Miki Excel Worksheet Functions 0 October 10th 07 03:27 PM
Help with Matching Text Fields - Then Moving the Matching Cells Side by Side [email protected] Excel Discussion (Misc queries) 2 June 11th 07 02:38 PM
Matching two cells bLOBBY Excel Worksheet Functions 3 October 2nd 06 02:01 PM
Matching cells GARY Excel Discussion (Misc queries) 2 August 23rd 06 07:06 AM
Matching cells [email protected] Excel Discussion (Misc queries) 0 July 1st 05 02:43 PM


All times are GMT +1. The time now is 07:22 PM.

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

About Us

"It's about Microsoft Excel"