I am trying to copy cell data from one sheet to another based on a match.
I have a workbook with 3 sheets. "Place", "Coke" and "HMS".
On Active sheet "Place", If column C14 has the word "Coke" - I want D14-H14 copied to the sheet "Coke".
Similarly if C15 contains "HMS" - I want only "D15-H15" Copied to the sheet "HMS"
I have a macro that copies the entire row while I want specific cells copied - which is from the specific C:H.
Sub As_Of_Analysis_Sorting()
Dim lr As Long, lr2 As Long, r As Long
lr = Sheets("Place").Cells(Rows.Count, "A").End(xlUp).Row
lr2 = Sheets("Coke").Cells(Rows.Count, "A").End(xlUp).Row
lr3 = Sheets("HMS").Cells(Rows.Count, "A").End(xlUp).Row
For r = lr To 2 Step -1
If Range("C" & r).Value = "Coke" Then
Rows(r).Copy Destination:=Sheets("Coke").Range("A" & lr2 + 1)
lr2 = Sheets("Coke").Cells(Rows.Count, "A").End(xlUp).Row
End If
If Range("C" & r).Value = "HMS" Then
Rows(r).Copy Destination:=Sheets("HMS").Range("A" & lr3 + 1)
lr3 = Sheets("HMS").Cells(Rows.Count, "A").End(xlUp).Row
End If
Range("A140").Select
Next r
End Sub
Hos do I achieve this?