Macro Find value & insert

W

wazzo

Hi I need some code to look for names in column 3, which match name in
range a1, then if it does inserting value in column 4 from range b2.
Thats it !
 
J

JLGWhiz

Sub findNcpy()
Dim c As Range
For Each c In Range("C" & Cells(Rows.Count, 3).End(xlUP).Row)
If c = Range("A1").Value Then
c.Offset(0 2) = Range("B4").Value
End If
Next
End Sub
 
M

Mike H

Hi,

Right click your sheet tab, view code and past this in and run it

Sub marine()
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
Set myrange = Range("C1:C" & lastrow)
For Each c In myrange
If c.Value = Range("A1").Value Then
c.Offset(, 1).Value = Range("B2").Value
End If
Next


Mike
 
M

Mike H

I'm sure you meant this or something similar :)

For Each c In Range("C1:C" & Cells(Rows.Count, 3).End(xlUp).Row)

Mike
 
J

JLGWhiz

Yes I did mean that. Mike. Thanks. Old age is catching up with me.
I had it right in my module for testing but neglected to correct the line
that I had priviously put on Note Pad to copy. Stuff happens:)
 
Top