jamescooper
Well-known Member
- Joined
- Sep 8, 2014
- Messages
- 840
I have the following code which tracks changes to cells in the appropriate columns.
I now want to add the following code which copies to another sheet when cell H1 says "Suspended". This works but then it continues to do this over and over and I only want it to do it once? Any ideas? Many thanks.
Code:
Private Sub Worksheet_Calculate()
nR = Cells(Rows.Count, "AG").End(xlUp).Row + 1
nR2 = Cells(Rows.Count, "AK").End(xlUp).Row + 1
nR3 = Cells(Rows.Count, "AO").End(xlUp).Row + 1
nR4 = Cells(Rows.Count, "AS").End(xlUp).Row + 1
nR5 = Cells(Rows.Count, "AW").End(xlUp).Row + 1
nR6 = Cells(Rows.Count, "BA").End(xlUp).Row + 1
inarr0 = Range("H1")
inarr = Range("K9:K10")
inarr2 = Range("K11:K12")
inarr3 = Range("K13:K14")
inarr4 = Range("K15:K16")
inarr5 = Range("K17:K18")
inarr6 = Range("K19:K20")
If inarr(1, 1) <> oldk9 Or inarr(2, 1) <> oldk10 Then
Application.EnableEvents = False
Range("AH" & nR) = inarr(1, 1)
Range("AI" & nR) = inarr(2, 1)
oldk9 = inarr(1, 1)
oldk10 = inarr(2, 1)
Sheets("Bet Angel").Range("F4").Copy Destination:=Sheets("Sheet1").Range("AG" & nR)
Application.EnableEvents = True
End If
End Sub
I now want to add the following code which copies to another sheet when cell H1 says "Suspended". This works but then it continues to do this over and over and I only want it to do it once? Any ideas? Many thanks.
Code:
If Range("H1") = "Suspended" Then
Range("AG1:BC1000").Copy Sheets("Data").Cells(Sheets("Data").Rows.Count, "B").End(xlUp).Offset(1, 0)