Rewrite Available VBA re: Worksheet_Change

love_guy_1977

Board Regular
Joined
Aug 5, 2006
Messages
111
Hi guys,

I need your help to combine & minimize this VAB


Code:
Private Sub Worksheet_Change(ByVal Target As Range)

 If Sheets("Working_Paper").Range("AJ12") > 1 And Sheets("Working_Paper").Range("AL12") > 1 Then
     Application.Undo
 End If

 If Sheets("Working_Paper").Range("AJ13") > 1 And Sheets("Working_Paper").Range("AL13") > 1 Then
     Application.Undo
 End If

 If Sheets("Working_Paper").Range("AJ14") > 1 And Sheets("Working_Paper").Range("AL14") > 1 Then
     Application.Undo
 End If

 If Sheets("Working_Paper").Range("AJ15") > 1 And Sheets("Working_Paper").Range("AL15") > 1 Then
     Application.Undo
 End If

 If Sheets("Working_Paper").Range("AJ16") > 1 And Sheets("Working_Paper").Range("AL16") > 1 Then
     Application.Undo
 End If

 If Sheets("Working_Paper").Range("AJ17") > 1 And Sheets("Working_Paper").Range("AL17") > 1 Then
     Application.Undo
 End If

 If Sheets("Working_Paper").Range("AJ18") > 1 And Sheets("Working_Paper").Range("AL18") > 1 Then
     Application.Undo
 End If

 If Sheets("Working_Paper").Range("AJ19") > 1 And Sheets("Working_Paper").Range("AL19") > 1 Then
     Application.Undo
 End If

End Sub

Thank you
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long

Application.EnableEvents = False


With Sheets("Working_Paper")
    For i = 12 To 19
        If .Cells(i, 36) > 1 And .Cells(i, 38) > 1 Then Application.Undo
    Next i
End With
    
Application.EnableEvents = True
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top