当前位置: 动力学知识库 > 问答 > 编程问答 >

excel - Adding a row with copied formulas that incorporate newly named worksheet

问题描述:

I have created a button that adds a new worksheet that is a copy of another worksheet and prompts the user for a name input. What I also would like it to do is to add a row in the ActiveSheet (which is neither of the sheets created or copied earlier) and copy the formulas of the row above but swap out the name of the referenced worksheet in the formulas with the name of the newly created worksheet.

I don't know if that is even possible and I am at a loss, if it is, with how to write that into my existing code. Please help.

Private Sub CopyRename_Click()

Dim sName As String

Dim wks As Worksheet

Worksheets("Bank Rec. (1)").Copy after:=Sheets(Worksheets.Count)

Set wks = ActiveSheet

Do While sName <> wks.Name

sName = Application.InputBox _

(Prompt:="Enter new worksheet name")

On Error Resume Next

wks.Name = sName

On Error GoTo 0

Loop

Set wks = Nothing

End Sub

分享给朋友:
您可能感兴趣的文章:
随机阅读: