Get a worksheet name using Excel VBA Ask Question Asked 8 years ago Active 10 months ago Viewed 334k times 16 2 I would like to create an userdefined function in Excel that can return the current worksheet I could use the sheetname = ActiveSheetName But the problem with this is, it works and suddenly it starts to get different sheet However I have run into another problem as a result of deleting this sheet If you know how to do it this way it would be better I think Here is what I do 1 Initialize an arrary 2 Populate the arrary with values from a database 3 Cycle through the array and create a worksheet for every name in the arrary VBAExcel Get the names of all WorkSheets in a Excel (WorkBook) Open a new Excel WorkBook and press "AltF11" to open the Visual Basic Editor Sheetscount will give you the number of sheets present in the Excel (WorkBook) Sheets (i)Name will fetch the Sheet Name based upon the index value, which is 'i' here

Sheet Name Code Excel Download Template Formula Example