+ Reply to Thread
Results 1 to 4 of 4

Copy a template sheet that is hidden!

Hybrid View

  1. #1
    Registered User
    Join Date
    05-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    83

    Red face Copy a template sheet that is hidden!

    Ive got a template sheet that ive hidden, im trying to copy it and assign a new name to the sheet according to what year the user types in. the problem im having is that when the tab is hidden the copy remains hidden and when I input a visible line everything goes wrong.

    Help Please

    Sub New_Condition_Survey()
    
    Dim SurveyYear As String
    
    SurveyYear = InputBox("What Year will the survey commence?", "Commencement Year")
    
    If SurveyYear = "" Then Exit Sub
    If IsNumeric(SurveyYear) Then
        If SurveyYear > 0 < 3000 Then
            ActiveWorkbook.Sheets("Condition Survey Template").Copy _
           after:=ActiveWorkbook.Sheets("Condition Survey Template")
            ActiveSheet.Name = SurveyYear & " - " & SurveyYear + 5 & " Condition Survey"
            ActiveSheet.Visible = True
        Else
            MsgBox "Invalid Year"
        End If
    End If
    
    End Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Copy a template sheet that is hidden!

    Why not make the template visible, copy it and then hide it again?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    05-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    83

    Re: Copy a template sheet that is hidden!

    Ive just tried that and I think that is the right way to do it, but there must be a problem with my code as its not showing the new tab, or sometimes it does and othertimes it doesn't and it renames the master tab.

    im think im getting confused with my activesheet bit.

    can you spot where im going wrong?

    thnaks

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: Copy a template sheet that is hidden!

    Perhaps you could try something other than ActiveSheet, or maybe do things in a slightly different order.

    For example, unhide template, copy it, rename new worksheet, which should be the active sheet, and then rehide the template sheet.

    Or, and this really depends what's on the template sheet, copy the contents of the template to a newly created sheet.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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