Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
GARY
 
Posts: n/a
Default matching cell contents

Column A is 73 characters wide and it has 23,628 rows.
Coumn B is 44 characters wide and it has 2,733 rows.

How can I eliminate the cells in Column A whose 16 left-most characters
do NOT match the 16 left-most characters in Column B?

  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default matching cell contents

You could do it with an array formula, but I think it would be quicker to use a
couple of helper columns.

In c1, put the truncated stuff from column B:
=left(b1,16)
and drag down

Now in d1, put this formula:
=isnumber(match(left(a1,16),c:c,0))

Then filter on on column D to show the Falses. Delete those visible rows and
delete the helper columns.



GARY wrote:

Column A is 73 characters wide and it has 23,628 rows.
Coumn B is 44 characters wide and it has 2,733 rows.

How can I eliminate the cells in Column A whose 16 left-most characters
do NOT match the 16 left-most characters in Column B?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
GARY
 
Posts: n/a
Default matching cell contents

Hi Dave,

In c1, how far down does =left(b1,16) get dragged? (23,628 rows or
2,733 rows)
In d1, how far down does =isnumber(match(left(a1,16),c:c,0)) get
dragged? ( (23,628 rows or 2,733 rows)

  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default matching cell contents

=left(b1,16)
needs to match the number of rows in column B.

=isnumber(match(left(a1,16),c:c,0))
needs to match the number of rows in column A.

GARY wrote:

Hi Dave,

In c1, how far down does =left(b1,16) get dragged? (23,628 rows or
2,733 rows)
In d1, how far down does =isnumber(match(left(a1,16),c:c,0)) get
dragged? ( (23,628 rows or 2,733 rows)


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
GARY
 
Posts: n/a
Default matching cell contents

Dave,

I didn't get the results I expected.

Here's what I did:

In C1, I entered: =left(b1,16)
and copied that formula and pasted it in C1 thru C2733.

In D1, I entered: =isnumber(match(left(a1,16),c:c,0))
and copied that formula and pasted it in D1 thru D23628.

I clicked on column D's heading, clicked on DATA then on AUTOFILTER,
clicked on the arrow in D1 and selected "False" from the drop-down
list.

I clicked Column D, clicked on EDIT/GO TO/SPECIAL/VISIBLE CELLS ONLY
and deleted the "helper" columns (C and D).

But column A still contains all 23,628 cells and column B still
contains all 2,733 cells.

What did I do wrong?



  #6   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default matching cell contents

Did you copy and paste those visible cells to a new location?

After you do that, you can delete columns A:D.

Actually, I'd paste to a new worksheet and keep my old stuff there--just in case
I needed it later. It's always easier to delete than recreate. (Well,
usually!)



GARY wrote:

Dave,

I didn't get the results I expected.

Here's what I did:

In C1, I entered: =left(b1,16)
and copied that formula and pasted it in C1 thru C2733.

In D1, I entered: =isnumber(match(left(a1,16),c:c,0))
and copied that formula and pasted it in D1 thru D23628.

I clicked on column D's heading, clicked on DATA then on AUTOFILTER,
clicked on the arrow in D1 and selected "False" from the drop-down
list.

I clicked Column D, clicked on EDIT/GO TO/SPECIAL/VISIBLE CELLS ONLY
and deleted the "helper" columns (C and D).

But column A still contains all 23,628 cells and column B still
contains all 2,733 cells.

What did I do wrong?


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.misc
GARY
 
Posts: n/a
Default matching cell contents

Dave,

Shouldn't I be click "TRUE"? (Then, the entries in column B seem to be
the ones that match those in column A).

  #8   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default matching cell contents

Show True if you want to copy and paste the visible cells.

Show False if you want to delete those visible cells.

GARY wrote:

Dave,

Shouldn't I be click "TRUE"? (Then, the entries in column B seem to be
the ones that match those in column A).


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default matching cell contents

Hi Gary,

How often do you have to do this?

Regards,
Bernd

  #10   Report Post  
Posted to microsoft.public.excel.misc
GARY
 
Posts: n/a
Default matching cell contents

I have three speadsheets. In each spreadsheet:

Col A has about 25,000 cells (len = 73).
Col B has about 3,000 cells (len = 44).

I need to determine, using the 16 left-most characters in Col A and Col
B, which of the cells in Col A "match" the cells in Col B.



  #11   Report Post  
Posted to microsoft.public.excel.misc
GARY
 
Posts: n/a
Default matching cell contents

Maybe I should re-state the situation.

I have three spreadsheets.

In each spreadsheet:

Col A has about 25,000 cells (len = 73).
Col B has about 3,000 cells (len = 44).

How can I determine, using the 16 leftmost characters in Col A and Col
B, which of the cells in Col A "match" the cells in Col B?

  #12   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default matching cell contents

Didn't the follow up to your click the True question help?

GARY wrote:

Maybe I should re-state the situation.

I have three spreadsheets.

In each spreadsheet:

Col A has about 25,000 cells (len = 73).
Col B has about 3,000 cells (len = 44).

How can I determine, using the 16 leftmost characters in Col A and Col
B, which of the cells in Col A "match" the cells in Col B?


--

Dave Peterson
  #13   Report Post  
Posted to microsoft.public.excel.misc
GARY
 
Posts: n/a
Default matching cell contents

Hi Dave,

I still must be doing something wrong.

Maybe if you will re-give me exact, step-by-step instructions I can
follow them more carefully.

Thanks,

Gary

  #14   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default matching cell contents

You have this:

Col A has about 25,000 cells (len = 73).
Col B has about 3,000 cells (len = 44).

In column C (25000 cells), put the first 16 characters of column A:
=left(a1,16)
and drag down 25000 cells

In column D (3000) cells, put the first 16 characters of column B.
=left(b1,16)
and drag down 3000 cells

In column E (25000) cells
put this formula
=isnumber(match(c1,d:d,0))

Now filter and show only the trues or falses.

You can delete the mismatches by showing falses
you can keep the matches by copying the visible cells (in column A) and pasting
them to a new sheet.

GARY wrote:

Hi Dave,

I still must be doing something wrong.

Maybe if you will re-give me exact, step-by-step instructions I can
follow them more carefully.

Thanks,

Gary


--

Dave Peterson
  #15   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default matching cell contents

Hi Gary,

I suggest to take this macro:
Option Explicit

Sub compare_substrings()
Dim coll As New Collection
Dim lr As Long, lidx As Long

On Error Resume Next
'first collect comparison values from column B
lr = 1
Do While Not IsEmpty(Cells(lr, 2))
coll.Add 0, "X" & Left(Cells(lr, 2).Text, 16)
lr = lr + 1
Loop

'then test all values in column A
lr = 1
Do While Not IsEmpty(Cells(lr, 1))
Err.Clear
lidx = coll("X" & Left(Cells(lr, 1).Text, 16))
If Err.Number < 0 Then
Cells(lr, 1).Interior.ColorIndex = 3 'red
'Cells(lr, 1).Delete Shift:=xlUp 'delete cell and shift others
up
Else
Cells(lr, 1).Interior.ColorIndex = 43 'lime
End If
lr = lr + 1
Loop

End Sub

This test version highlights your cells. Uncomment the delete command
to eliminate cells which do not match (and comment the line above that
one...)

HTH,
Bernd

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
Adding the contents of a cell to a formula Paul Bond Excel Discussion (Misc queries) 1 January 21st 06 07:19 PM
Conversion of Cell Contents into a Functional Worksheet name ? GMJT Excel Worksheet Functions 1 August 21st 05 04:59 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
How do I find the contents of a cell using the "ADDRESS" function. sweeney Excel Worksheet Functions 2 April 5th 05 03:23 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 11:29 AM.

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"