Notifications
Clear all

Contar Shapes em determinado range

3 Posts
2 Usuários
0 Reactions
1,044 Visualizações
(@mueldavc)
Posts: 24
Eminent Member
Topic starter
 

Olá Masters.

Estou utilizando a função Sheets(1).shapes.count para saber quantas textbox exitem nesta planilha, só que isso ainda não resolveu o meu problema, estou tentando saber quantas Text boxs existem em um determinado range.
Por ex:
Sheets(1).range("A1:G100").shapes.count

Mas essa instrução não funciona. Alguém saberia a forma correta?

Também me utilizei da função:

For each sh in sheets(1).shapes

next

Me retornou o sh (shape) como objeto que ai sim me resolveu muito.

Agradeço a todos.

 
Postado : 04/02/2016 7:40 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

mueldavc, veja se é isto ...

Public Sub Contagem()
    Dim Sh
    Dim C As Long
    Dim Ci As Long
    
    C = 0
    Ci = 0
    For Each Sh In Sheets(1).Shapes
        If Not Intersect(Sheets(1).Range("A1:G100"), Sh.TopLeftCell) Is Nothing Then
            Ci = Ci + 1
        End If
        
        C = C + 1
    Next
    
    MsgBox "Encontrados: " & C & vbCrLf & vbCrLf & "Na região: " & Ci & vbCrLf & vbCrLf, vbInformation
End Sub
 
Postado : 04/02/2016 2:56 pm
(@mueldavc)
Posts: 24
Eminent Member
Topic starter
 

alexandre_eng

Meu amigo. Perfeito. Coube como uma luva.

Abraço

 
Postado : 05/02/2016 6:57 am