Hello -
I'm new to the forum but not new to Excel VBA. I'm having a problem passing an argument. I've written a number of Excel macros, but they've been simple and done within a single module or didn't require passing of arguments. This seems very simple, yet I'm having trouble with it. Can anyone assist and let me know what I'm doing wrong please? Thank you!
I'm new to the forum but not new to Excel VBA. I'm having a problem passing an argument. I've written a number of Excel macros, but they've been simple and done within a single module or didn't require passing of arguments. This seems very simple, yet I'm having trouble with it. Can anyone assist and let me know what I'm doing wrong please? Thank you!
Code:
Option Explicit
Public wkshtSelected As String ' declaring my variable
Private Sub cboSheetNames_Change()
wkshtSelected = frmUserPrompt.cboSheetNames.Value ' setting variable to value user selects from combo box on form (values are all sheets in this workbook)
Sheets(wkshtSelected).Select ' select that worksheet
End Sub
Private Sub cmdLoadExpenses_Click(ByRef wkshtSelected As Worksheet) ' now that wkshtSelected has value, I'm trying to pass it to this sub for further code but get following error
'Compile error: Procedure declaration does not match description of event or procedure having the same name.
'other code will go here once argument passing error is resolved
End Sub