Consulting

Results 1 to 4 of 4

Thread: Insert Template Macro

  1. #1

    Insert Template Macro

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Sub AddTemplate()
    Worksheets("Template").Copy After:=Worksheets(ActiveSheet.Index)
    Worksheets(ActiveSheet.Index + 1).Visible = xlSheetVisible
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    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

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Then you need to qualify it with the template workbook.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •