Em muitas ocasiões, pelos mais diversos motivos, precisamos saber os nomes de todas as worksheets disponíveis em nossas planilhas.
Function ListSheets()
' Author: Date: Contact: URL:
' André Bernardes 08/08/2010 08:33 bernardess@gmail.com http://al-bernardes.sites.uol.com.br/
' Lista todas as planilhas existentes no Workbook.
Dim ws As Worksheet
Dim x As Integer
Dim nSheet As String
Let Application.ScreenUpdating = False
Let Application.DisplayAlerts = False
Let Application.EnableEvents = False
Let nSheet = "Analyse" ' Worksheet que receberá a lista com os nomes.
Let x = 3
Sheets(nSheet).Select
Sheets(nSheet).Range("C:C").Clear
For Each ws In Worksheets
Let Sheets(nSheet).Cells(x, 3) = ws.Name
Let x = x + 1
Next ws
Let Application.ScreenUpdating = True
Let Application.DisplayAlerts = True
Let Application.EnableEvents = True
End Function
Tags: Excel, worksheet, list, listsheet