Sub GetSheetNames()
Dim wb As Workbook
Dim ws As Worksheet
Dim sheetNames As String
Dim outputSheet As Worksheet
Dim rowIndex As Long
Set wb = ActiveWorkbook
Set outputSheet = ActiveWorkbook.Sheets.Add
outputSheet.Range("A1").Value = "Sheet Names"
rowIndex = 2
For Each ws In wb.Sheets
outputSheet.Cells(rowIndex, 1).Value = ws.Name
rowIndex = rowIndex + 1
Next ws
outputSheet.Columns.AutoFit
MsgBox "Ðã lấy thành công danh sách tên sheet!", vbInformation
End Sub
Nhận xét
Đăng nhận xét