Hello everyone,
I'm trying to make a spreadsheet with a macro that asks the user for the Case ID (case_id), and creates a new sheet which is copied from a template (wsTemp). I then want to rename the new sheet with the case ID that the user provided, and also enter the case ID in the cell A1 of the new sheet.
That's where the problem is. For some reason, Excel creates a sheet and calls it "Template (2)" instead using the case ID. It also does not change the value of cell A1. Any ideas?
I'm trying to make a spreadsheet with a macro that asks the user for the Case ID (case_id), and creates a new sheet which is copied from a template (wsTemp). I then want to rename the new sheet with the case ID that the user provided, and also enter the case ID in the cell A1 of the new sheet.
That's where the problem is. For some reason, Excel creates a sheet and calls it "Template (2)" instead using the case ID. It also does not change the value of cell A1. Any ideas?
VBA Code:
Sub new_case_macro ()
Dim wsTemp As Worksheet
Dim case_id As String
case_id InputBox ("Enter Case ID: ")
With ThisWorkbook
Set wsTemp Sheets ("Template") wsTemp.Copy Before:-.Sheets (.Sheets.Count)
ActiveSheet.Range ("Al").Value -case_id
ActiveSheet.Name = case_id
End With
End Sub