Iluvpresident
Iluvpresident

Reputation: 175

Two events in one Sub

Private Sub btnBestellen_Enter()
Call bestelling()
End Sub

Private Sub btnBestellen_Click()
Call bestelling()
End Sub

I have two seperate subs here with the same code in it. Is there any possible way to make it into one sub? For example like this, of course this doesn't work.

Thank you in advance

Private Sub btnBestellen_Click,btnBestellen_Enter()
Call bestelling()
End Sub

Upvotes: 1

Views: 305

Answers (1)

Anthony Sherratt
Anthony Sherratt

Reputation: 475

Unfortunately not. VBA has no syntax for grouping Event Subs as you described.

The only work around would be to create a listener function that checks for your events manually. It would be down to you to catch them and handle them correctly. Although I'm guessing that would be out of scope here :)

Upvotes: 2

Related Questions