Be the first user to complete this post

  • 0
Add to List

VBA-Excel: Get the names of all WorkSheets in a Excel (WorkBook)

  • Open a new Excel WorkBook and press “Alt+F11” to open the Visual Basic Editor
  • Copy Paste the following code
Sub FnGetSheetsName()

Dim mainworkBook As Workbook

Set mainworkBook = ActiveWorkbook

For  i = 1 To mainworkBook.Sheets.count

‘Either we can put all names in an array , here we are printing all the names in Sheet 2

mainworkBook.Sheets(“Sheet2”).Range(“A” & i) = mainworkBook.Sheets(i).Name

Next i

End Sub
  • Run the Macro
All WorkSheets Names
All WorkSheets Names



Sheets.count 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.

Also Read about:

Also Read:

  1. VBA-Excel: Create a WorkBook at Runtime.
  2. How to Enable Macro in Excel
  3. VBA-Excel: Copy/Paste data - Copy the Entire row data and paste it to another row
  4. VBA-Excel: Create Dynamic or Run-time WorkSheets using Macro.
  5. VBA-Excel: CurrentRegion
  6. Excel-VBA : Prevent Adding New Worksheet
  7. VBA-Excel: SUDOKU Solver
  8. VBA-Excel: Get all the WeekDays or Working days in Specified Date Range, (excluding Satudays and Sundays)