+ Reply to Thread
Results 1 to 6 of 6

macro to organise location of new duplicated sheets automatically

  1. #1
    Registered User
    Join Date
    11-30-2018
    Location
    London
    MS-Off Ver
    2016
    Posts
    5

    macro to organise location of new duplicated sheets automatically

    Hi All,

    i've created the following macro on excel 2016 below which duplicates template sheets. i have three different kinds, a CAI, CCR, and EWQ template macro. after each sheet is copied the user will enter in a number to name it, so the sheet names will look like, for example, CAI 001, CAI 002, CCR 001, etc.

    I've set the macro to insert the new sheet at the end of the workbook every time - but is there a way i can organise the location of the new duplicated sheet to automatically be moved after the section? for example, if i add a new CAI sheet, it doesn't go to the end of the workbook, but instead goes after the last CAI numbered sheet, but before the CCR sheet section starts? and then all the CCR sheets are in the middle, but the EWQ numbered sheets will always go to the end anyway.. hopefully that makes sense!


    # Sub Copy_CAI_Template()

    Dim Actsheet As String
    Application.ScreenUpdating = False
    On Error Resume Next
    ActiveWorkbook.Sheets("CAI Template").Visible = True
    ActiveWorkbook.Sheets("CAI Template").Copy _
    After:=Sheets(Sheets.Count)
    ActNm = ActiveSheet.Name
    ActiveSheet.Name = "CAI " & InputBox("Enter new CAI reference number")
    Sheets(ActiveSheet.Name).Visible = True
    ActiveWorkbook.Sheets("CAI Template").Visible = False
    Application.ScreenUpdating = True
    End Sub #


    i'd appreciate any help!
    Last edited by TExcel_; 12-06-2018 at 01:37 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,265

    Re: macro to organise location of new duplicated sheets automatically

    Perhab like this
    Please Login or Register  to view this content.
    Or you can try change this line
    Please Login or Register  to view this content.
    Become
    Please Login or Register  to view this content.
    Last edited by daboho; 11-30-2018 at 11:57 AM.

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,230

    Re: macro to organise location of new duplicated sheets automatically

    Hi TEexcel

    Your post does not comply with rule2 of the Forum's rules...

    2. Programming code must be enclosed in code tags to improve readability. (A, Z)
    Please Login or Register  to view this content.
    (or use the # button)
    To expedite a solution, please comply with the above...Also add a sample file to make use of...
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Registered User
    Join Date
    11-30-2018
    Location
    London
    MS-Off Ver
    2016
    Posts
    5

    Re: macro to organise location of new duplicated sheets automatically

    hey daboho, thanks for the reply - unfortunately i couldn't get your coding to work.

    can you give me some more pointers please?

    What does "Sheets(s(i))" refer to as i'm assuming i need to rename the "i"? in the other section you typed "j-1" and wasn't sure what i need this to refer to?

  5. #5
    Registered User
    Join Date
    11-30-2018
    Location
    London
    MS-Off Ver
    2016
    Posts
    5

    Re: macro to organise location of new duplicated sheets automatically

    i added the #, but it doesn't seem to have enclosed it in a box like it does in your post?

  6. #6
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,265

    Re: macro to organise location of new duplicated sheets automatically

    Ok try this your code
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. macro to just automatically open the pdf file in a location and copy it and paste in XL
    By catchnanan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-29-2018, 09:29 AM
  2. Macro to automatically add the workbook to trusted location upon opening
    By king05 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2017, 08:30 AM
  3. Macro to pull file from folder location Automatically
    By Ngutierr in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-06-2015, 04:35 AM
  4. Macro to change formulas to a new location on all sheets
    By danfullwood in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-05-2015, 03:51 AM
  5. Rows added by macro sometimes automatically duplicated in shared excel file
    By Prince Skeleth in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-15-2014, 02:46 PM
  6. Need help with folder location automatically updating on macro
    By jhonperu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2013, 02:51 PM
  7. Automatically sort by location --each location having it's own sheet
    By blacky69 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 12-02-2008, 03:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1