ok.. let's simplify; or clarify what to do here.. you want to do the following:
* Create a new sheet from one of two templates, based on name in a cell value
* rename the new template according to column C:E (not specified which row??)
have a look at the following code (untested) and see if you can use that.
Since you never specified the row, the macro takes hold of the row you've currently selected
Sub test()
Dim rValue As Integer ' create an integer value called rValue
rValue = ActiveCell.Row ' set rValue to the number of the row you're in
Dim templateSelect As String
templateSelect = Sheet1.Range("E" & rValue).Value ' stores the name of the cell in a variable
Dim sheetName As String 'the name of the sheet to be created
sheetName = Sheet1.Range("C" & rValue).Value & " " & Sheet1.Range("D" & rValue).Value & " " & Sheet1.Range("E" & rValue).Value ' sets the name
msgbox (sheetName) 'A messagebox just for you to see what the sheetname will be based on the above line of code. Comment out this later on after fiddlin' with the code.
' we assume that column E always contains only Motor, Contractor or other (Motor + Contractor) to determine which template to call
'** now to check which template to use***
If templateSelect = "Motor" Then GoTo motor
If templateSelect = "Contractor" Then GoTo contractor
'if none above is correct, it must correspond to "Motor + Contractor" and the code for that template should go here.
MsgBox ("Motor + Contractor code not yet selected template")
Exit Sub
motor:
Sheets("NAME OF MOTOR TEMPLATE HERE").Select
Sheets("NAME OF MOTOR TEMPLATE HERE").Copy Before:=Sheets(2)
Sheets("NAME OF MOTOR TEMPLATE HERE (2)").Name = (sheetName)
Exit Sub
contractor:
Sheets("NAME OF CONTRACTOR TEMPLATE HERE").Select
Sheets("NAME OF CONTRACTOR TEMPLATE HERE").Copy Before:=Sheets(2)
Sheets("NAME OF CONTRACTOR TEMPLATE HERE (2)").Name = (sheetName)
Exit Sub
End Sub
Bookmarks