Excel Vba Set Active Sheet - Web dim wb as workbook set wb = workbooks(example.xlsx) ' this line of code activates the worksheet named summary in the referenced workbook. Web 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. Example = sheets(exampleworksheet).cells(x,y) so you get rid of messing around with an active or not active worksheets. Answered oct 25, 2017 at 6:48. Sub activatesheet(sheetname as string) 'selects sheet of specific name sheets(sheetname).select end sub To get the activesheet name: Web to set the activesheet use worksheet.activate: Web so if you want to take an information form a particular sheet you can use this: Instead you can use the vba code name for the worksheet: Have questions or feedback about office vba or this.
Or you can use the.select function like so: Web makes the current sheet the active sheet. Instead you can use the vba code name for the worksheet: Example = sheets(exampleworksheet).cells(x,y) so you get rid of messing around with an active or not active worksheets. Expression a variable that represents a worksheet object. Web to set the activesheet use worksheet.activate: Web 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. Web so if you want to take an information form a particular sheet you can use this: Calling this method is equivalent to choosing the sheet's tab. To get the activesheet name: The activate sheet command will actually “go to” the sheet, changing the visible sheet. Answered oct 25, 2017 at 6:48. Have questions or feedback about office vba or this. Wb.sheets(summary).activate end sub note that the above code will give you an error if the name of the workbook or the worksheet you want to refer to is incorrect or if the workbook is not already open. Web dim wb as workbook set wb = workbooks(example.xlsx) ' this line of code activates the worksheet named summary in the referenced workbook. Sub activatesheet(sheetname as string) 'selects sheet of specific name sheets(sheetname).select end sub The above example uses the sheet (tab) name.