Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
Avatar do usuário
Por wesleyribeiro123
Posts Avatar
#18307
Pessoal
Bom dia,

Estou com seguinte problema, criei uma macro que relaciona todas as guias (Abas) do Excel numa ListBox (com propriedade de multiplas seleções). A ideia é que o usuário possa selecionar as guias que ele deseja exibir e/ou ocultar e de OK fazendo com que as guias selecionadas de fato se ocultem ou reexibam.

O meu problema está em como fazer com que o VBA identifique a Sheet selecionada no ListBox. Estou utilizando o seguinte código:
Código: Selecionar todos
Dim x As Integer

For x = 0 To OcultaReexibe.ListBox1.ListCount - 1
    If OcultaReexibe.ListBox1.List.Selected(x) Then
       If Sheets(x).Visible = True Then
          Sheets(x).Visible = False
       Else: Sheets(x).Visible = True
       End If
    End If
Next
Este código retorna um erro informando que o objeto é obrigatório...
Se puderem me ajudar!!! Obrigado
Avatar do usuário
Por wesleyribeiro123
Posts Avatar
#18310
Galera

Estudando aqui meu código acabei conseguindo resolver o problema :) :D
Código: Selecionar todos
For x = 0 To OcultaReexibe.ListBox1.ListCount
On Error Resume Next
    If OcultaReexibe.ListBox1.Selected(x) Then
       If Sheets(x + 1).Visible = True Then
          Sheets(x + 1).Visible = False
       Else: Sheets(x + 1).Visible = True
       End If
    End If
Next
De qualquer forma, obrigado pelo espaço, rsrs
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord