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
Por SandroLima
#40576
Boa tarde.

Como eu faço para excluir apenas a coluna 1 do ajuste automático ao alterar os dados de uma tabela no evento change de uma planilha??

Aqui ajusta todas as colunas:
Código: Selecionar todos
Tabela.Range.EntireColumn.AutoFit
Mas eu preciso que a primeira coluna não faça o ajuste de largura automático.

Obrigado
Por osvaldomp
#40580
Testaí...
Código: Selecionar todos
 With Range("Tabela")
   .Columns(2).Resize(, .Columns.Count-1).AutoFit 
 End With
Avatar do usuário
Por Jimmy
Avatar
#40582
osvaldomp escreveu:
Código: Selecionar todos
 With Range("Tabela")
   .Columns(2).Resize(, .Columns.Count-1).AutoFit 
 End With
Acho que o Osvaldo quis dizer:
Código: Selecionar todos
 With Sheets("Tabela")
      .Columns(2).Resize(, .Columns.Count-1).AutoFit 
 End With
Jimmy San Juan
Por SandroLima
#40585
Boa noite, Osvaldomp.

Boa noite, Jimmy.

Tentei as duas maneiras propostas mas não funcionou. O código no final ficou assim:
Código: Selecionar todos
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim Tabela As ListObject
        
    Set Tabela = wshBDClientes.ListObjects("TB_Clientes")
    
    Application.ScreenUpdating = False
    
    With Range("Tabela")
        .Columns(2).Resize(, .Columns.Count - 1).AutoFit
    End With

    Application.ScreenUpdating = True

    Set Tabela = Nothing

End Sub
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