How to activate a specific worksheet in Excel?

后端 未结 3 825
挽巷
挽巷 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条回答
  •  死守一世寂寞
    2020-12-13 09:05

    I would recommend you to use worksheet's index instead of using worksheet's name, in this way you can also loop through sheets "dynamically"

    for i=1 to thisworkbook.sheets.count
     sheets(i).activate
    'You can add more code 
    with activesheet
     'Code...
    end with
    next i
    

    It will also, improve performance.

提交回复
热议问题