loke2002249
New Member
- Joined
- May 2, 2019
- Messages
- 5
Hello, everyone..
i need some help to make this repetitive VBA into a very simple VBA
My repetitive VBA were shown as below
If Target.Address = "$L$6" Then
a = Sheets("Price Record").Cells(Rows.Count, "A").End(xlUp).Row + 1
Sheets("Price Record").Range("A" & a).Value = Sheets("MasterItemPriceList").Range("M6").Value
End If
If Target.Address = "$L$6" Then
a = Sheets("Price Record").Cells(Rows.Count, "B").End(xlUp).Row + 1
Sheets("Price Record").Range("B" & a).Value = Sheets("MasterItemPriceList").Range("L6").Value
End If
If Target.Address = "$L$7" Then
a = Sheets("Price Record").Cells(Rows.Count, "C").End(xlUp).Row + 1
Sheets("Price Record").Range("C" & a).Value = Sheets("MasterItemPriceList").Range("M7").Value
End If
If Target.Address = "$L$7" Then
a = Sheets("Price Record").Cells(Rows.Count, "D").End(xlUp).Row + 1
Sheets("Price Record").Range("D" & a).Value = Sheets("MasterItemPriceList").Range("L7").Value
End If
If Target.Address = "$L$8" Then
a = Sheets("Price Record").Cells(Rows.Count, "E").End(xlUp).Row + 1
Sheets("Price Record").Range("E" & a).Value = Sheets("MasterItemPriceList").Range("M8").Value
End If
If Target.Address = "$L$8" Then
a = Sheets("Price Record").Cells(Rows.Count, "F").End(xlUp).Row + 1
Sheets("Price Record").Range("F" & a).Value = Sheets("MasterItemPriceList").Range("L8").Value
End If
If Target.Address = "$L$9" Then
a = Sheets("Price Record").Cells(Rows.Count, "G").End(xlUp).Row + 1
Sheets("Price Record").Range("G" & a).Value = Sheets("MasterItemPriceList").Range("M9").Value
End If
If Target.Address = "$L$9" Then
a = Sheets("Price Record").Cells(Rows.Count, "H").End(xlUp).Row + 1
Sheets("Price Record").Range("H" & a).Value = Sheets("MasterItemPriceList").Range("L9").Value
End If
If Target.Address = "$L$10" Then
a = Sheets("Price Record").Cells(Rows.Count, "I").End(xlUp).Row + 1
Sheets("Price Record").Range("I" & a).Value = Sheets("MasterItemPriceList").Range("M10").Value
End If
If Target.Address = "$L$10" Then
a = Sheets("Price Record").Cells(Rows.Count, "J").End(xlUp).Row + 1
Sheets("Price Record").Range("J" & a).Value = Sheets("MasterItemPriceList").Range("L10").Value
End If
and so on.....
i need some help to make this repetitive VBA into a very simple VBA
My repetitive VBA were shown as below
If Target.Address = "$L$6" Then
a = Sheets("Price Record").Cells(Rows.Count, "A").End(xlUp).Row + 1
Sheets("Price Record").Range("A" & a).Value = Sheets("MasterItemPriceList").Range("M6").Value
End If
If Target.Address = "$L$6" Then
a = Sheets("Price Record").Cells(Rows.Count, "B").End(xlUp).Row + 1
Sheets("Price Record").Range("B" & a).Value = Sheets("MasterItemPriceList").Range("L6").Value
End If
If Target.Address = "$L$7" Then
a = Sheets("Price Record").Cells(Rows.Count, "C").End(xlUp).Row + 1
Sheets("Price Record").Range("C" & a).Value = Sheets("MasterItemPriceList").Range("M7").Value
End If
If Target.Address = "$L$7" Then
a = Sheets("Price Record").Cells(Rows.Count, "D").End(xlUp).Row + 1
Sheets("Price Record").Range("D" & a).Value = Sheets("MasterItemPriceList").Range("L7").Value
End If
If Target.Address = "$L$8" Then
a = Sheets("Price Record").Cells(Rows.Count, "E").End(xlUp).Row + 1
Sheets("Price Record").Range("E" & a).Value = Sheets("MasterItemPriceList").Range("M8").Value
End If
If Target.Address = "$L$8" Then
a = Sheets("Price Record").Cells(Rows.Count, "F").End(xlUp).Row + 1
Sheets("Price Record").Range("F" & a).Value = Sheets("MasterItemPriceList").Range("L8").Value
End If
If Target.Address = "$L$9" Then
a = Sheets("Price Record").Cells(Rows.Count, "G").End(xlUp).Row + 1
Sheets("Price Record").Range("G" & a).Value = Sheets("MasterItemPriceList").Range("M9").Value
End If
If Target.Address = "$L$9" Then
a = Sheets("Price Record").Cells(Rows.Count, "H").End(xlUp).Row + 1
Sheets("Price Record").Range("H" & a).Value = Sheets("MasterItemPriceList").Range("L9").Value
End If
If Target.Address = "$L$10" Then
a = Sheets("Price Record").Cells(Rows.Count, "I").End(xlUp).Row + 1
Sheets("Price Record").Range("I" & a).Value = Sheets("MasterItemPriceList").Range("M10").Value
End If
If Target.Address = "$L$10" Then
a = Sheets("Price Record").Cells(Rows.Count, "J").End(xlUp).Row + 1
Sheets("Price Record").Range("J" & a).Value = Sheets("MasterItemPriceList").Range("L10").Value
End If
and so on.....