jamescooper
Well-known Member
- Joined
- Sep 8, 2014
- Messages
- 840
Hello, the following code populates the codes of cell K9 if it is changed in the next available row in column AL and K10 in the next available in AV and F4 in the next available in AK.
However, this only happens if the cell is changed manually by entering in. My excel spreadsheet is linked to software where the cell can change without this happening; any idea how I would adapt my code to achieve any changes?
Thanks.
However, this only happens if the cell is changed manually by entering in. My excel spreadsheet is linked to software where the cell can change without this happening; any idea how I would adapt my code to achieve any changes?
Thanks.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim nR As Long
nR = WorksheetFunction.Max(2, Sheets("Bet Angel").Range("AL" & Rows.Count).End(xlUp).Row + 1)
If Not Intersect(Target, Sheets("Bet Angel").Range("K9:K10")) Is Nothing Then
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
Sheets("Bet Angel").Range("K9").Copy Destination:=Sheets("Bet Angel").Range("AL" & nR)
Sheets("Bet Angel").Range("K10").Copy Destination:=Sheets("Bet Angel").Range("AV" & nR)
Sheets("Bet Angel").Range("F4").Copy Destination:=Sheets("Bet Angel").Range("AK" & nR)
End If
End Sub