仕事でちょっと使ったVBA集
'開いている別エクセル(確認.xlsx)のシート名を
'B列3行目から列挙する
Public Sub getSheet()
Dim mySheet As Worksheet
Dim trgBook As Workbook
Set mySheet = ActiveSheet
Set trgBook = Workbooks("確認.xlsx")
Dim i As Long
For i = 1 To trgBook.Sheets.Count
mySheet.Cells(i + 2, 2).Value = trgBook.Worksheets(i).Name
Next i
End Sub
'B列3行目から列挙する
Public Sub getSheet()
Dim mySheet As Worksheet
Dim trgBook As Workbook
Set mySheet = ActiveSheet
Set trgBook = Workbooks("確認.xlsx")
Dim i As Long
For i = 1 To trgBook.Sheets.Count
mySheet.Cells(i + 2, 2).Value = trgBook.Worksheets(i).Name
Next i
End Sub