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
#24742
Olá Pessoal,
Modelo anexo é um simples modelo só pra exemplificar meu problema.
Eu tenho uma estrutura bem mais complexa e estou tentando fazer um filtro avançado com uma aba protegida e está gerando um erro na macro, no modelo anexo a aba consulta está protegida não tem senha cadastrada só está protegida, nela contem um filtro avançado que busca informações da aba Base.
Se alguém tiver uma ideia de resolver agradeço!
Abraço!
Você não está autorizado a ver ou baixar esse anexo.
#24746
Boa tarde!!

Onde está sua rotina?
Protect method as it applies to the Worksheet object.

Protects a worksheet so that it cannot be modified.

expression.Protect(Password, DrawingObjects, Contents, Scenarios, UserInterfaceOnly, AllowFormattingCells, AllowFormattingColumns, AllowFormattingRows, AllowInsertingColumns, AllowInsertingRows, AllowInsertingHyperlinks, AllowDeletingColumns, AllowDeletingRows, AllowSorting, AllowFiltering, AllowUsingPivotTables)
expression Required. An expression that returns a Worksheet object.

Password Optional Variant. A string that specifies a case-sensitive password for the worksheet or workbook. If this argument is omitted, you can unprotect the worksheet or workbook without using a password. Otherwise, you must specify the password to unprotect the worksheet or workbook. If you forget the password, you cannot unprotect the worksheet or workbook. It's a good idea to keep a list of your passwords and their corresponding document names in a safe place.

DrawingObjects Optional Variant. True to protect shapes. The default value is False.

Contents Optional Variant. True to protect contents. For a chart, this protects the entire chart. For a worksheet, this protects the locked cells. The default value is True.

Scenarios Optional Variant. True to protect scenarios. This argument is valid only for worksheets. The default value is True.

UserInterfaceOnly Optional Variant. True to protect the user interface, but not macros. If this argument is omitted, protection applies both to macros and to the user interface.

AllowFormattingCells Optional Variant. True allows the user to format any cell on a protected worksheet. The default value is False.

AllowFormattingColumns Optional Variant. True allows the user to format any column on a protected worksheet. The default value is False.

AllowFormattingRows Optional Variant. True allows the user to format any row on a protected. The default value is False.

AllowInsertingColumns Optional Variant. True allows the user to insert columns on the protected worksheet. The default value is False.

AllowInsertingRows Optional Variant. True allows the user to insert rows on the protected worksheet. The default value is False.

AllowInsertingHyperlinks Optional Variant. True allows the user to insert hyperlinks on the worksheet. The default value is False.

AllowDeletingColumns Optional Variant. True allows the user to delete columns on the protected worksheet, where every cell in the column to be deleted is unlocked. The default value is False.

AllowDeletingRows Optional Variant. True allows the user to delete rows on the protected worksheet, where every cell in the row to be deleted is unlocked. The default value is False.

AllowSorting Optional Variant. True allows the user to sort on the protected worksheet. Every cell in the sort range must be unlocked or unprotected. The default value is False.

AllowFiltering Optional Variant. True allows the user to set filters on the protected worksheet. Users can change filter criteria but can not enable or disable an auto filter. Users can set filters on an existing auto filter. The default value is False.

AllowUsingPivotTables Optional Variant. True allows the user to use pivot table reports on the protected worksheet. The default value is False.

Remarks
If you apply the Protect method with the UserInterfaceOnly argument set to True to a worksheet and then save the workbook, the entire worksheet (not just the interface) will be fully protected when you reopen the workbook. To re-enable the user interface protection after the workbook is opened, you must again apply the Protect method with UserInterfaceOnly set to True.

If changes wanted to be made to a protected worksheet, it is possible to use the Protect method on a protected worksheet if the password is supplied. Also, another method would be to unprotect the worksheet, make the necessary changes, and then protect the worksheet again.

Note 'Unprotected' means the cell may be locked (Format Cells dialog) but is included in a range defined in the Allow Users to Edit Ranges dialog, and the user has unprotected the range with a password or been validated via NT permissions.
Att
#24778
Bom dia!!


Anacleto, porque não simplesmente desprotege e protege a guia?
Código: Selecionar todos
Sub Filtro()
'
' Filtro Macro
    ActiveSheet.Unprotect '<-- Desproteger
    Range("A3:B4").Select
    Sheets("Base").Columns("A:J").AdvancedFilter Action:=xlFilterCopy, _
        CriteriaRange:=Range("A3:B4"), CopyToRange:=Range("Consulta!Extract"), _
        Unique:=False
        
    Range("D8").Select
    ActiveSheet.Protect '<-- Proteger
End Sub
Favor ler as regras do fórum, e indicar as postagens cruzadas!
http://www.planilhando.com.br/forum/vie ... 10&t=25369

Att
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