Selective elimination of code execution.

lynx653

New Member
Joined
Feb 6, 2019
Messages
2
In the code below, recording TO respective sheets works well...
recording FROM respective sheets changes the value in B3 thus execute the recording TO respective sheets again... the former is essential, how to stop the latter ?

Private Sub Worksheet_Change(ByVal Target As Range)


Dim myWS As String ' gets the form/year that is similar to sheet to copy/record
myWS = Sheet1.Range("B1").Value ' say F1 (sheet name)


Dim myL As String ' gets the lesson num in sow
myL = Sheet1.Range("B2").Value ' say 1


If Not Intersect(Target, Range("B3:B11")) Is Nothing Then ' recording to respectives sheets


Worksheets("Sheet1").Range("B3").Copy Worksheets(myWS).Range("A" & myL & "") 'copy to sheet F1 cell A1


End If


If Not Intersect(Target, Range("B1:B2")) Is Nothing Then ' recording from respective sheets


Worksheets(myWS).Range("A" & myL & "").Copy Worksheets("Sheet1").Range("B3")


End If


End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Code:
If Not Intersect(Target, Range("B1:B2")) Is Nothing Then ' recording from respective sheets
  Application.EnableEvents = False
  Worksheets(myWS).Range("A" & myL & "").Copy Worksheets("Sheet1").Range("B3")
  Application.EnableEvents = True
End If
 
Upvote 0
exact.... problem solved... thank you so much...

Code:
If Not Intersect(Target, Range("B1:B2")) Is Nothing Then ' recording from respective sheets
  Application.EnableEvents = False
  Worksheets(myWS).Range("A" & myL & "").Copy Worksheets("Sheet1").Range("B3")
  Application.EnableEvents = True
End If
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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