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
#49582
Olá,
Tenho uma macro que desprotege a planilha, atualiza uma tabela dinâmica quando ocorre modificação em determinado campo e protege a planilha novamente.
Problema é que essa proteção é padrão, preciso que ao proteger a planilha fique liberado a formatação de células, alguns usuários da planilha pintam as células para identificação, como ta a planilha agora essa função fica bloqueada.
segue código da macro utilizada:

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = True

If Not Intersect(Target, Range("L9:L4616")) Is Nothing Then

Call Worksheet_Activate

End If

End Sub

Private Sub Worksheet_Activate()

Const CsSenha As String = "PROJ2019"
Dim pt As PivotTable
ActiveSheet.Unprotect CsSenha
Worksheets("bayface").PivotTables("CTOREPETIDA").PivotCache.Refresh
ActiveSheet.Protect CsSenha, DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
Application.CellDragAndDrop = True
End Sub

Obrigado!
#49592
Olá Mauricio,

Tente alterar essa parte da macro.
Troque
ActiveSheet.Protect CsSenha, DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
Por
ActiveSheet.Protect CsSenha, DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
, AllowFormattingCells:=True

Se quiser permitir também a formatação de colunas ou linhas, inclua:
, AllowFormattingColumns:=True, AllowFormattingRows:=True

Se esta mensagem colabora para a solução do problema, peço que dê um Like, clicando no botão com o "positivo", acima e a direita.

Jimmy San Juan
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