Copy an entire worksheet to a new worksheet in Excel 2010

前端 未结 6 1424
长发绾君心
长发绾君心 2020-12-01 10:28

I have found similar questions that deal with copying an entire worksheet in one workbook and pasting it to another workbook, but I am interested in simply copying an entire

6条回答
  •  醉梦人生
    2020-12-01 11:17

    If anyone has, like I do, an Estimating workbook with a default number of visible pricing sheets, a Summary and a larger number of hidden and 'protected' worksheets full of sensitive data but may need to create additional visible worksheets to arrive at a proper price, I have variant of the above responses that creates the said visible worksheets based on a protected hidden "Master". I have used the code provided by @/jean-fran%c3%a7ois-corbett and @thanos-a in combination with simple VBA as shown below.

    Sub sbInsertWorksheetAfter()

        'This adds a new visible worksheet after the last visible worksheet
    
        ThisWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
    
        'This copies the content of the HIDDEN "Master" worksheet to the new VISIBLE ActiveSheet just created
    
        ThisWorkbook.Sheets("Master").Cells.Copy _
            Destination:=ActiveSheet.Cells
    
        'This gives the the new ActiveSheet a default name
    
        With ActiveSheet
            .Name = Sheet12.Name & " copied"
        End With
    
        'This changes the name of the ActiveSheet to the user's preference
    
        Dim sheetname As String
    
        With ActiveSheet
            sheetname = InputBox("Enter name of this Worksheet")
            .Name = sheetname
        End With
    

    End Sub

提交回复
热议问题