03Explorer
Technical User
I found a solution to do this but with Excel 365 it is not allowing it. I am building a Sub to do this... Code below:
I am stuck with MySheetName = . VBA is not allowing me to use an example I found.
Code:
Sub PopulateExcel(strName, strNameID, strPractice, strRole, strServiceType)
Dim MyXL As Object
Dim MySheetName As String
'copy Sheet1
Select Case strRole
Case "CRM"
Debug.Print "CRM is the primary value."
'open Excel file as defined in CompiledDirectory
Set MyXL = CreateObject("Excel.Application")
MySheetName = strNameID & "-" & strName Sheets("Sheet1").Copy After:=wb.Worksheets(wb.Worksheets.Count) 'compile new sheet name
Debug.Print "New Tab Name = '& MySheetName & " '"
ActiveSheet.Name = MySheetName 'activate new sheet
I am stuck with MySheetName = . VBA is not allowing me to use an example I found.
Code:
Sub CopySheet()
Dim MySheetName As String
MySheetName = "TestSheet" Sheets("MasterSheet").Copy After:=Sheets("MasterSheet")
ActiveSheet.Name = MySheetName
End Sub