Página 1 de 1

Concatenar Objeto e Variável

Enviado: 06 Fev 2018 às 15:40
por Lurosan
Pessoal, boa tarde.
Estou há tempos tentando resolver um problema; mas sem sucesso!! :|

Inserir alguns Controles ActiveX numa planilha, por exemplo: Label1, Label2..., e um CommandButton1.

Tenho este comando que deixam todos os objetos não visíveis, com exceção do CommandButton:
Worksheets("Plan3").OLEObjects.Visible = False
CommandButton1.Visible = True

Meu desafio é deixar visível a Label1 se o texto da célula A1 = Label1, deixar visível a Label2 se o texto da célula A1 = Label2

Muito agradecido.

Re: Concatenar Objeto e Variável

Enviado: 06 Fev 2018 às 16:56
por osvaldomp
Experimente:
Código: Selecionar todos
Sub ExibeLabel()
 Dim objX As Object
  With Sheets("Plan3")
   For Each objX In .OLEObjects
    If objX.Name = .[A1] Then objX.Visible = True
   Next
  End With
End Sub

Concatenar Objeto e Variável

Enviado: 06 Fev 2018 às 20:49
por Lurosan
Oswaldo, muito obrigado cara.
Me ajudou muito.
Sucesso pra você!!!!! :D