View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Find in Column A and Remove from Column B

then use instr

from:
If StrComp(cell, cell.Offset(rowoffset:=0, columnoffset:=1)) = 0 Then
cell.Delete Shift:=xlToLeft

If instr(cell.Offset(rowoffset:=0, columnoffset:=1),cell) 0 Then
cell.Delete Shift:=xlToLeft


"Johnny B" wrote:

Thanks Joel!, this only works if Column A is identical to the entire cell in
column B.
For example

|American Online | American Online |

running the macro will give

|American Online | (empty) |

however, if there is

|American Online | American Online, John Johnson |

nothing happens. Running the macro will give:

|American Online | American Online, John Johnson |

thanks for your help!

~johnny b

"Joel" wrote:

try this code

Sub CompareAB()

Lastrow = Cells(Rows.Count, 1).End(xlUp).Row

Set MyRange = Range(Cells(1, 1), Cells(Lastrow, 1))

For Each cell In MyRange

If StrComp(cell, cell.Offset(rowoffset:=0, columnoffset:=1)) = 0 Then

cell.Delete Shift:=xlToLeft
End If


Next cell

End Sub


"Johnny B" wrote:

Hey Guys, I was wondering if there was a way to create a macro (not
substitute or concatonate) that would Find information from Column A and
Remove it from Column B.
For Example:

from
| Column A | Column B|
| American Online | American Online, Bob |
| Google.com | Google.com 123 Fake Street |

to
| Column A | Column B|
| American Online | , Bob |
| Google.com | 123 Fake Street |

THANKS!!!!

~johnny b