OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 421
- Office Version
- 2019
- Platform
- Windows
Hello and thanks in advance. How would I have have an error message pop up if a Macro Button is not selected as depending on which button is selected, it uses this text within it to execute different parts of the sub/macro.
This is what I have so far, but I still get the error "Run-time error '1004': Unable to get the Buttons property of the Worksheet class!
This is what I have so far, but I still get the error "Run-time error '1004': Unable to get the Buttons property of the Worksheet class!
VBA Code:
Option Explicit
Sub MacroTextButton()
Dim MacroText As String
Dim ShtNm As String
ShtNm = "Sheet1"
With Sheets(ShtNm)
MacroText = .Buttons(Application.Caller).Caption
If MacroText = "" Then
MsgBox "You did not select a Macro Button! This Macro/Sub will be exited! Please select a button the next time"
Exit Sub
End If
End With
End Sub