Notifications
Clear all

Lista com nome das Sheets

5 Posts
2 Usuários
0 Reactions
1,016 Visualizações
(@xmiguelx)
Posts: 34
Trusted Member
Topic starter
 

Olá pessoal,

Preciso de um help:

1. Tenho uma planilha com uma Sheet (PRINCIPAL).
2. Nessa Sheet tem um botão (LISTA DE SHEETs).
3. Ao clicar no botão (Lista de Sheets), ele lista a partir da célula E1 o nome de todas as Sheets.

Objetivo.
A. Ao clicar no Botão (Lista de Sheets) seja listado o nome das sheets a partir da coluna H10 com o seguinte critério:

Apenas o nome das Sheets que tenha o botão (DIVERSOS).

Estou colocando um exemplo em anexo,

Desde já obrigado pela ajuda.

 
Postado : 22/09/2016 12:07 pm
(@issamu)
Posts: 0
New Member
 

Fiz alguns incrementos no seu código associado ao botão:

Sub GetSheets()
    Dim j As Integer
    Dim NumSheets As Integer
    Dim shp As Shape
    
    NumSheets = Sheets.Count
    
    Range("H10:H" & Rows.Count).ClearContents
    
    For j = 1 To NumSheets
        Sheets(j).Activate
        Sheets("PRINCIPAL").Cells(j, 5) = Sheets(j).Name
        
        For Each shp In Sheets(j).Shapes
            shp.Select
            If Selection.Characters.Text = "DIVERSOS" Then
                Sheets("PRINCIPAL").Range("H" & Rows.Count).End(xlUp).Offset(1, 0).Value = Sheets(j).Name
            End If
        Next shp
        
    Next j
    
    Sheets("PRINCIPAL").Activate
    Range("H10").Activate
End Sub
 
Postado : 22/09/2016 1:13 pm
(@xmiguelx)
Posts: 34
Trusted Member
Topic starter
 

Bom dia Amigo!

Quando adiciono em qualquer Sheet um comentário do Excel, ao clicar no botão (LISTA DE SHEETs) ocorre um erro em tempo de execução.

Poderia me ajudar?

Abs

 
Postado : 23/09/2016 4:27 am
(@issamu)
Posts: 0
New Member
 

Interessante, quadro do comentário é um shape, então pelo código há um comando para selecionar o shape, mas como o comentário está oculto, dá erro por não conseguir selecionar. A solução é colocar mais um if perguntando se o shape está visivel, se tiver segue, senão pula. Ficaria:

Sub GetSheets()
    Dim j As Integer
    Dim NumSheets As Integer
    Dim shp As Shape
    
    NumSheets = Sheets.Count
    
    Range("H10:H" & Rows.Count).ClearContents
    
    For j = 1 To NumSheets
        Sheets(j).Activate
        Sheets("PRINCIPAL").Cells(j, 5) = Sheets(j).Name
        
        For Each shp In Sheets(j).Shapes
        If shp.Visible Then
            shp.Select
            If Selection.Characters.Text = "DIVERSOS" Then
                Sheets("PRINCIPAL").Range("H" & Rows.Count).End(xlUp).Offset(1, 0).Value = Sheets(j).Name
            End If
        End If
        Next shp
        
    Next j
    
    Sheets("PRINCIPAL").Activate
    Range("H10").Activate
End Sub
 
Postado : 23/09/2016 7:26 am
(@xmiguelx)
Posts: 34
Trusted Member
Topic starter
 

Muito obrigado Amigo!

Ficou perfeito.

Abs

 
Postado : 23/09/2016 8:05 am