Hi all!
So i have a workbook that has about 30 hidden 'template' sheets in it, and one worksheet open with the name of each sheet and a button The button brings up an application box which renames the copied template to what you type. The idea is I have one main workbook that I can copy into every job folder, and with ease you can build the test file for all the equipment on a specific site. I have a separate module made for each potential sheet, which is then assign to its corresponding button. The code is:
Each module pretty much looks the same:
The issue I am having is even though everything is its own module referencing different sheets, it will eventually create a copy of the sheet I want, but actually rename the previous template sheet. As in I run my HVCircuitBreaker sub...it makes a copy of the HVCircuitBreaker_Temp, and renames it based on the application box. I then try to make a ThreePhaseRelay worksheet, it copies the proper template but leave me with THREE PHASE RELAY_TEMP(2), and renames HV CIRCUIT BREAKER_TEMP to my application box input.
Is it because each module has the variable IDX? Any help is mucho appreciated!
So i have a workbook that has about 30 hidden 'template' sheets in it, and one worksheet open with the name of each sheet and a button The button brings up an application box which renames the copied template to what you type. The idea is I have one main workbook that I can copy into every job folder, and with ease you can build the test file for all the equipment on a specific site. I have a separate module made for each potential sheet, which is then assign to its corresponding button. The code is:
VBA Code:
Sub New_HV_CircuitBreaker_Sheet()
Dim WSName As String: WSName = Application.InputBox("Enter New SheetName")
Dim IDX As Integer: IDX = Sheets("HV CIRCUIT BREAKER_TEMP").Index
Sheets("HV CIRCUIT BREAKER_TEMP").Visible = True
Sheets("HV CIRCUIT BREAKER_TEMP").Copy After:=Sheets(IDX)
Sheets("HV CIRCUIT BREAKER_TEMP").Visible = Flase
Sheets(IDX + 1).Name = WSName
End Sub
Each module pretty much looks the same:
Code:
Sub New_Three_Phase_Relay_Sheet()
Dim WSName As String: WSName = Application.InputBox("Enter New SheetName")
Dim IDX As Integer: IDX = Sheets("THREE PHASE RELAY_TEMP").Index
Sheets("THREE PHASE RELAY_TEMP").Visible = True
Sheets("THREE PHASE RELAY_TEMP").Copy After:=Sheets(IDX)
Sheets("THREE PHASE RELAY_TEMP").Visible = Flase
Sheets(IDX + 1).Name = WSName
End Sub
The issue I am having is even though everything is its own module referencing different sheets, it will eventually create a copy of the sheet I want, but actually rename the previous template sheet. As in I run my HVCircuitBreaker sub...it makes a copy of the HVCircuitBreaker_Temp, and renames it based on the application box. I then try to make a ThreePhaseRelay worksheet, it copies the proper template but leave me with THREE PHASE RELAY_TEMP(2), and renames HV CIRCUIT BREAKER_TEMP to my application box input.
Is it because each module has the variable IDX? Any help is mucho appreciated!