check value in cells against all values in a column
Hi Finn,
This macro searches colummn D for the value in C3 and if true replaces it
with the value in A3. You should be able to follow the logic to do the other
columns.
Sub Macro2()
Dim lastrow As Long
checkvalue = Cells(3, 3).Value
replacevalue = Cells(3, 1)
lastrow = Cells(Cells.Rows.Count, "d").End(xlUp).Row
For x = lastrow To 1 Step -1
Cells(x, 4).Select
foundvalue = Cells(x, 4).Value
If foundvalue = checkvalue Then
Cells(x, 4).Value = replacevalue
End If
Next
End Sub
Mike
"Finn" wrote:
"Mike" wrote:
The logic for this is confusing:-
compare C3 to columns D,F & H
if any values are the same as B3 replace them with the value in A3
C3 is therefore never actually used. Please clarify
Mike
Compare value inn "C3" with values in all cells inn D,F &H and with any
duplicates too value in C3 exchange with value inn "A3" , next go to "C4" and
do the same routine but now exhange values with "A4" until it reach end
|