Hi MrExcel,
I created a generic userform which can work with multiple worksheets.
I have a macro in a module that will execute some code to export the sheet to another workbook. (i.e. macro name = Export_BOM_CostSummary() , or Export_BOM_PcsPc() etc.)
The sheet that I want to export has a portion of the macro name. (i.e. sheet name = BOM_CostSummary, or BOM_PcsPc etc.)
From my user form, when I click the Export command button the following should happen: (as I understand it)
Private Sub cmdExport_Click()
'*****************************<wbr>******************************<wbr>******************
'Load Active Workbook Sheet Name
'*****************************<wbr>******************************<wbr>******************
Dim AWS As String 'Active Workbook Sheet Name (AWS)
ActiveSheet.Select
AWS = ActiveSheet.Name ' BOM_CostSummary or BOM_PcsPc
'*****************************<wbr>******************************<wbr>******************
'Create Macro Name to be used
'*****************************<wbr>******************************<wbr>******************
Dim expMacro As String 'Export Macro
expMacro = "Export_" + AWS ' This creates the macro name to be called, (i.e. Export_BOM_CostSummary or Export_BOM_PcsPc)
'*****************************<wbr>******************************<wbr>******************
The expMacro returns the string value as: Export_BOM_CostSummary or Export_BOM_PcsPc
But I do not know what to do further to call the macro with the same name.
I created a generic userform which can work with multiple worksheets.
I have a macro in a module that will execute some code to export the sheet to another workbook. (i.e. macro name = Export_BOM_CostSummary() , or Export_BOM_PcsPc() etc.)
The sheet that I want to export has a portion of the macro name. (i.e. sheet name = BOM_CostSummary, or BOM_PcsPc etc.)
From my user form, when I click the Export command button the following should happen: (as I understand it)
Private Sub cmdExport_Click()
'*****************************<wbr>******************************<wbr>******************
'Load Active Workbook Sheet Name
'*****************************<wbr>******************************<wbr>******************
Dim AWS As String 'Active Workbook Sheet Name (AWS)
ActiveSheet.Select
AWS = ActiveSheet.Name ' BOM_CostSummary or BOM_PcsPc
'*****************************<wbr>******************************<wbr>******************
'Create Macro Name to be used
'*****************************<wbr>******************************<wbr>******************
Dim expMacro As String 'Export Macro
expMacro = "Export_" + AWS ' This creates the macro name to be called, (i.e. Export_BOM_CostSummary or Export_BOM_PcsPc)
'*****************************<wbr>******************************<wbr>******************
The expMacro returns the string value as: Export_BOM_CostSummary or Export_BOM_PcsPc
But I do not know what to do further to call the macro with the same name.