I have a macro that fires when bets are placed, this issue is if another workbook is open it will cause an error in the macro, what can i add so i can have other sheets open with the same macro and not cause an error.
- Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Columns.Count <> 16 Then Exit Sub
Application.EnableEvents = False
With ThisWorkbook
If .Sheets("Data").Range("T2").Value <> 1 Then
.Sheets("Data").Range("T3").Value = 0
End If
If .Sheets("Data").Range("T2").Value = 1 And Sheets("Data").Range("T3").Value <> 1 Then
.Sheets("Results").Range("N" & Rows.Count).End(xlUp).Offset(1, 0).Resize(24, 2).Value = Sheets("Control").Range("AD15:AE55").Value
.Sheets("Data").Range("T3").Value = 1
End If
Application.EnableEvents = True
End With
End Sub