How to activate a specific worksheet in Excel?

I just need to activate a specific sheet. I have a string variable that saves the name of the worksheet.

+48
vba excel
Oct 25 '10 at 10:44
source share
3 answers

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 use the .Activate function. Or you can use the .Select function as follows:

 Sub activateSheet(sheetname As String) 'selects sheet of specific name Sheets(sheetname).Select End Sub 
+84
Oct. 25 '10 at 11:08
source share

I would recommend that you use a worksheet index instead of using a worksheet name, so you can also cycle 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.

+4
Jan 6 '17 at 23:09 on
source share

An alternative (non-dynamic) way to link text to activate a worksheet without macros is to make the selected line an actual link. You can do this by selecting the cell that contains the text and press CTRL + K, then select the โ€œPlace in this documentโ€ option / tab and select the tab that you want to activate. If you click on the text (now this is a link), the customized sheet will become active / selected.

0
Nov 30 '15 at 15:36
source share



All Articles