Get a worksheet name using Excel VBA

后端 未结 6 859
名媛妹妹
名媛妹妹 2021-01-08 01:29

I would like to create an user-defined function in Excel that can return the current worksheet. I could use the

sheetname = Activ         


        
6条回答
  •  终归单人心
    2021-01-08 01:56

    You can use below code to get the Active Sheet name and change it to yours preferred name.

    Sub ChangeSheetName()
    
    Dim shName As String
    Dim currentName As String
    currentName = ActiveSheet.Name
    shName = InputBox("What name you want to give for your sheet")
    ThisWorkbook.Sheets(currentName).Name = shName
    
    End Sub
    

提交回复
热议问题