Hello Warderbrad,
The Application.Caller will return a string which is the name of the Forms Button that was clicked. Using a Select Case statement is the easiest and most efficient method of selecting the code to be run. Replace the button names if yours are different.
Sub ButtonMacro()
Dim Btn As String
Btn = Application.Caller
Select Case Btn
Case Is "Button 1"
'Place Button 1's code here
Case Is "Button 2"
'Place Button 2's code here
Case Is "Button 3"
'Place Button 3's code here
Case Is "Button 4"
'Place Button 4's code here
Case Is "Button 5"
'Place Button 5's code here
End Select
End Sub
To run the same code if the button matches any 1 of the 5, use this example...
Sub ButtonMacro()
Dim Btn As String
Select Case Btn
Case Is "Button 1", "Button 2", "Button 3", "Button 4", "Button 5"
'Place code here
End Select
Sincerely,
Leith Ross
Bookmarks