ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Look for cells with same value in different columns (https://www.excelbanter.com/excel-programming/357633-look-cells-same-value-different-columns.html)

FB[_2_]

Look for cells with same value in different columns
 
I need to create a macro that:

For all cells in a column, find the cells with similar values in
another column (whereas all cells are different in the first column,
there can be several identical cells in the second one) and paste the
cells next to them in a third column (this I know how to do!).

I am a beginner using VBA, and quite helpless on this issue! Thanks in
advance for your help!
Franck


FB[_2_]

Look for cells with same value in different columns
 
Below is the code I use. When I run the macro, there is no error
message - but nothing happens!


Sub CopyIdenticalCells()

Dim ColumnI As Range
Dim i As Range
Dim ColumnL As Range
Dim y As Range

Set ColumnI = Range("I3", Range("I" &
Rows.Count).End(xlUp).Address)
Set ColumnL = Range("L3", Range("L" &
Rows.Count).End(xlUp).Address)
For Each i In ColumnI
If i < "" Then
For Each y In ColumnL
If y = i Then
i.Offset(0, 1).Copy Range("O" &
Rows.Count).End(xlUp).Offset(1)
End If
Next y
End If
Next i

End Sub


What is wrong with it?

Franck


FB[_2_]

Look for cells with same value in different columns
 
PROBLEM SOVED - NO NEED FOR ASSISTANCE - THANKS



All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com