PDA

View Full Version : Insert Template Macro



bhn5001
10-20-2009, 07:50 AM
Hey all,

I'm new to programming and am trying to write a macro that will allow me to insert a template from a hidden workbook to the right of the active worksheet in the active workbook with just a keystroke. Any help would be very appreciated,

Thanks,

Brad

Bob Phillips
10-20-2009, 08:22 AM
Sub AddTemplate()
Worksheets("Template").Copy After:=Worksheets(ActiveSheet.Index)
Worksheets(ActiveSheet.Index + 1).Visible = xlSheetVisible
End Sub

bhn5001
10-20-2009, 10:19 AM
xld,

this code works if I run it in the workbook that contains the template. If I run it in another open workbook, however, it returns

subject errorr '9' subscript out of range

any ideas on how to fix this?

Thanks,

Brad

Bob Phillips
10-20-2009, 10:36 AM
Then you need to qualify it with the template workbook.