Run VBA-code after Private Sub Worksheet_SelectionChange(ByVal Target As Range)

KlausW

Active Member
Joined
Sep 9, 2020
Messages
469
Office Version
  1. 2016
Platform
  1. Windows
Hi,
can anyone help me get this VBA code to run when a code that starts with Private Sub Worksheet_SelectionChange(ByVal Target As Range) is run?

The vba codes are in the same sheet.

All help would be appreciated.

Best regards Klaus W

VBA Code:
Sub macro1()

Static Passed As Boolean

Dim P$

If Target.Address <> "$A$42" Or Passed Then Exit Sub

Do

P = InputBox(vbLf & vbLf & "Indtast adgangskode for at ændre denne celle:", "Begrænset adgang")

If P = "" Then Target(1, 2).Select: Exit Sub

Loop Until P = "XXXXXXX"

Passed = True

End Sub
 
Hi Tube 77, as it should be, thank you. And to everyone else who has come up with ideas to solve my challenge. Thank you too. Good day to everyone from Klaus W in Denmark
Nice to hear we were able to help and thanks for the feedback!
 
Upvote 0

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