How to activate a specific worksheet in Excel?

后端 未结 3 845
挽巷
挽巷 2020-12-13 08:33

I just need to activate a certain worksheet. I have a string variable that keeps the name of the worksheet.

3条回答
  •  旧时难觅i
    2020-12-13 08:46

    Would the following Macro help you?

    Sub activateSheet(sheetname As String)
    'activates sheet of specific name
        Worksheets(sheetname).Activate
    End Sub
    

    Basically you want to make use of the .Activate function. Or you can use the .Select function like so:

    Sub activateSheet(sheetname As String)
    'selects sheet of specific name
        Sheets(sheetname).Select
    End Sub
    

提交回复
热议问题