PDA

View Full Version : Find value in column and copy value from row above in another column



kurtwagner
12-04-2012, 04:40 AM
Hello, I have a problem that's probably very simple to solve:

I want a macro that searches for the word "NF" (without quotes) in column B. If true, than for that row for the columns D to AV, it should copy the value of the cell above.

patel
12-04-2012, 04:52 AM
attach a sample file with also desired result

kurtwagner
12-04-2012, 04:57 AM
Here is a sample:

patel
12-04-2012, 01:04 PM
Sub a()
LR = Cells(Rows.Count, "B").End(xlUp).Row
For j = 2 To LR
If Cells(j, 2).Value = "NF" Then
Range("C" & j & ":E" & j).Value = Range("C" & j - 1 & ":E" & j - 1).Value
End If
Next
End Sub

Teeroy
12-04-2012, 01:40 PM
Which is correct, your statement in post #1 that D:AV values should copy or C:E as per your sample? If it's post #1 you'll need to change the column references in Patel's Range statement.