Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing two cells in Excel

Status
Not open for further replies.

Lego15

Technical User
Dec 6, 2008
9
US
Hello,
I need some help on how I can compare two cells in Excel and return a certain value in cell3:

Data:

Cell1= excel data Cell2= excel data review and automation

I want to return the following on cell3
Cell3= review and automation

Base on what Cell1 & Cell2 have in common, remove the word match in Cell2 and return remaining of Cell2 in Cell3.

Is this possible?

Thank You in advance for your advise!
 
Hi

"Is this possible?"

Probably, but I can't really understand what you are asking. Maybe you could post an example.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Also please post what code you have tried to implement so far.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
This is an example:

Cell1 value= Bounty Cell2 value= Bounty Paper Product 10 rolls
I want cell3 value= Paper Product 10 rolls.

I am using a task automation software and it works but it skips some rows for some reason and do not really know why so I am trying to find another way to complete the task.
Is it clear now?

Thanks,
 
Will the phrase in cell1 always be the first part of the phrase in cell2?

 
Assuming that there is ALWAYS a match, and that it is ALWAYS the first part:

=RIGHT(B1,LEN(B1)-LEN(A1)-1)

 
You can use the Split function to parse the words in cell2
Code:
dim a, i as integer
a = split(cells(1,2).value," ")
for i = 0 to ubound(a)
  if cells(1,1).value <> a(i) then
     cells(1,3).value = cells(1,3).value & " " & a(i)
  end if
next
or it could be a function...
Code:
function CleanString(cel1 as string, cel2 as string) as string
  dim a, i as integer
  a = split(cel2value," ")
  for i = 0 to ubound(a)
    if cel1 <> a(i) then
       CleanString = CleanString & " " & a(i)
    end if
  next
end function


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
There will always be a match.

The formula above works but the first letter doesn't come up.

In this example the cell3 value= roduct 10 rolls
The P of Product is cut.
How can I fix that?

Thanks a bunch for your help!
 
Get rid of the extra spaces at the end of whatever is in cell1
 
How do I do that using a formula?

Thanks!
 
=RIGHT(B1,LEN(B1)-LEN(TRIM(A1))-1)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes it does!
I cannot thank you enough. I really appreciate your taking you time to help.

Take care,

Lego
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top