Dica: outros idiomas são traduzidos pelo Google. Você pode visitar o English versão deste link.
Entrar
x
or
x
x
Registre-se
x

or

Como agrupar e desagrupar linhas na planilha protegida?

Como todos sabemos, em uma planilha protegida, há muitas limitações para que possamos aplicar algumas operações. Como, não podemos alternar entre dados agrupados e não agrupados. Existe uma maneira de agrupar ou desagrupar linhas em uma planilha protegida?

Agrupe e desagrupe linhas em uma planilha protegida com código VBA

Guia do Office Habilitar Edição e Navegação por Guias no Office e Facilitar seu Trabalho ...
Kutools for Excel - A melhor ferramenta de produtividade do Office resolverá a maioria dos problemas do Excel
  • Reutilizar qualquer coisa: Adicione as fórmulas, gráficos e outras coisas mais usadas ou complexas aos seus favoritos e reutilize-os rapidamente no futuro.
  • Mais do que recursos de texto 20: Extrair Número da Cadeia de Texto; Extrair ou remover parte dos textos; Converta números e moedas em palavras inglesas ...
  • Mesclar Ferramentas: Várias pastas de trabalho e folhas em um; Mesclar várias células / linhas / colunas sem perder dados; Mesclar linhas duplicadas e soma ...
  • Ferramentas de divisão: Dados divididos em várias folhas com base no valor; Uma pasta de trabalho para vários arquivos Excel, PDF ou CSV; Uma coluna para várias colunas ...
  • Colar pulando Linhas ocultas / filtradas; Contagem e Soma pela cor de fundo; Criar lista de discussão e Envie e-mails pelo valor da célula...
  • Super Filtro: Crie esquemas de filtro avançados e aplique a qualquer folha; tipo por semana, dia, frequência e mais; filtros por negrito, fórmulas, comentário ...
  • Mais de recursos poderosos do 300; Funciona com o Office 2007-2019 e 365; Suporta todos os idiomas; Fácil implantação na empresa; Recursos completos Avaliação gratuita de um dia de 60.

arrow blue right bubble Agrupe e desagrupe linhas em uma planilha protegida com código VBA


Talvez, não haja outra boa maneira de resolver este problema, mas usando um código VBA, faça o seguinte:

1. Ative sua planilha que deseja usar, certifique-se de que a planilha ainda não está protegida.

2. Em seguida, segure o ALT + F11 chaves, e abre o Janela Microsoft Visual Basic for Applications.

3. Clique inserção > Móduloe cole o seguinte código no Janela Módulo.

Código VBA: agrupe e desengrue as linhas em uma planilha protegida

Sub EnableOutlining()
'Update 20140603
Dim xWs As Worksheet
Set xWs = Application.ActiveSheet
Dim xPws As String
xPws = Application.InputBox("Password:", xTitleId, "", Type:=2)
xWs.Protect Password:=xPws, Userinterfaceonly:=True
xWs.EnableOutlining = True
End Sub

4. Então aperte F5 chave para executar este código, e uma caixa de prompt aparecerá para lembrá-lo de inserir a senha para proteger a planilha atual. Ver captura de tela:

Doc-group-in-protected-sheet1

5. Então clique OK, sua planilha foi protegida, mas você pode expandir e contratar os símbolos do esboço nesta planilha protegida, veja a captura de tela:

Doc-group-in-protected-sheet1

notas: Se a sua planilha já está protegida, esse código não funcionará.


Kutools for Excel - A Melhor Ferramenta de Produtividade no Escritório Aumenta Sua Produtividade em 80%

  • armadilha para peixes: Inserir rapidamente fórmulas complexas, gráficos e qualquer coisa que você tenha usado antes; Criptografar células com senha; Criar lista de endereços e enviar e-mails ...
  • Bar Super Fórmula (facilmente editar várias linhas de texto e fórmula); Layout de leitura (leia e edite facilmente grandes números de células); Colar para intervalo filtrado...
  • Mesclar células / linhas / colunas sem perder dados; Conteúdo de células divididas; Combinar linhas / colunas duplicadas... Prevenir Células Duplicadas; Comparar intervalos...
  • Selecione Duplicado ou Exclusivo Linhas; Selecione linhas em branco (todas as células estão vazias); Super Find e Fuzzy Find em muitos livros de trabalho; Seleção aleatória ...
  • Cópia exata Múltiplas Células sem alterar a referência da fórmula; Criar automaticamente referências para várias folhas; Inserir marcadores, Caixas de seleção e mais ...
  • Extrair texto, Adicionar texto, remover por posição, Remover espaço; Criar e imprimir subtotais de paginação; Converter entre conteúdo de células e comentários...
  • Super Filtro (salve e aplique esquemas de filtro a outras planilhas); Classificação Avançada por mês / semana / dia, frequência e mais; Filtro especial por negrito, itálico ...
  • Combinar pastas de trabalho e planilhas; Mesclar tabelas com base em colunas-chave; Dividir dados em várias planilhas; Lote Converter xls, xlsx e PDF...
  • Mais de recursos poderosos do 300. Suporta Office / Excel 2007-2019 e 365. Suporta todos os idiomas. Fácil implantação em sua empresa ou organização. Recursos completos Avaliação gratuita de um dia de 60.
kte tab 201905

A guia Office traz a interface com guias para o Office e torna seu trabalho muito mais fácil

  • Ativar edição e leitura com guias no Word, Excel, PowerPoint, Publisher, Access, Visio e Project.
  • Abra e crie vários documentos em novas guias da mesma janela, em vez de em novas janelas.
  • Aumenta sua produtividade em 50% e reduz centenas de cliques do mouse para você todos os dias!
fundo officetab
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Dean Fabella · 5 months ago
    How To Group And Ungroup Rows and Columns In Protected Worksheet?
  • To post as a guest, your comment is unpublished.
    Jorge · 7 months ago
    formidable
  • To post as a guest, your comment is unpublished.
    EddieYeah · 8 months ago
    Someone might need this, I think I figured out how to make this work.

    First, your code needs to be written in "ThisWorkbook" under Microsoft Excel Objects, as @peachyclean suggests.
    Second, take the code that @Sravanthi wrote, and paste to the above mentioned location.

    Sub Workbook_Open()
    'Update 20140603
    Dim xWs As Worksheet
    Set xWs = Application.ActiveSheet
    Dim xPws As String
    xPws = "rfc" ''Application.InputBox("Password:", xTitleId, "", Type:=2)
    xWs.Protect Password:=xPws, Userinterfaceonly:=True
    xWs.EnableOutlining = True
    End Sub

    The thing is that you need to be on the sheet which you want to protect but allowing using grouping, and save the workbook and close, without protecting. Now if you open it, the macro starts automatically, it will make the sheet protected with the password "rfc". Now you can use the grouping, the sheet is protected.

    For my solution, I've modified the password applied, so you can rewrite any password HERE:
    xPws = "WRITEANYPASSWORDHERE" ''Application.InputBox("Password:", xTitleId, "", Type:=2)

    Furthermore, I didn't want the to-be-protected sheet active when opening the file, therefore I've modified this part:
    Set xWs = Application.ActiveSheet ->
    Set xWs = Application.Worksheets("WRITEANYSHEET'SNAMEHERE")

    Now it works like charm, sheet named 'WRITEANYSHEET'SNAMEHERE' is protected but the grouping applicable. On the long run, I think the problem will be that if I want to modify this file and keep the solution, I need to unprotect this sheet to make it work on the next opening. I guess you can write another macro to automatically unprotect when closing :)


    I hope it helped.
  • To post as a guest, your comment is unpublished.
    Denise · 1 years ago
    do you have visuals for the VBA Code discussed 6 days ago to peachyclean about ThisWorkbook under Microsoft Objects instead of a new module. The functionality is lost when I go back into my workbook
  • To post as a guest, your comment is unpublished.
    peachyclean · 1 years ago
    To fix the issue of this not working in your file after you've closed it and opened it again, you have to paste the VBA code in "ThisWorkbook" under Microsoft Excel Objects instead of a new module. This will then automatically run the macro every time the file is opened.
  • To post as a guest, your comment is unpublished.
    Susan · 1 years ago
    I have gotten this code to work. But when I close and reopen I must go to the developer tab, select the macros button, select run and enter the password.

    Is there a way to remove the password from the code OR a auto run code that will automatically run the this marco and enter the password?
  • To post as a guest, your comment is unpublished.
    Sravanthi · 1 years ago
    Sub Workbook_Open()
    'Update 20140603
    Dim xWs As Worksheet
    Set xWs = Application.ActiveSheet
    Dim xPws As String
    xPws = "rfc" ''Application.InputBox("Password:", xTitleId, "", Type:=2)
    xWs.Protect Password:=xPws, Userinterfaceonly:=True
    xWs.EnableOutlining = True
    End Sub
  • To post as a guest, your comment is unpublished.
    Neelash · 1 years ago
    this works for a bit, once you close and reopen, it stops :(
  • To post as a guest, your comment is unpublished.
    Arav · 2 years ago
    When i use the command, i see a error message as shown below:
    Private Sub Workbook_Open()
    Dim wsh As Variant
    For Each wsh In Worksheets(Array("TD_ phase_3", "RS_Phase_2"))
    wsh.EnableOutlining = True
    wsh.Protect Password:="260615", DrawingObjects:=False, _
    contents:=True, _
    Scenarios:=True, _
    AllowFiltering:=True, _
    AllowFormattingCells:=True, _
    userinterfaceonly:=True
    Next wsh
    End Sub
    Run time error '9':
    Subscript out of range
  • To post as a guest, your comment is unpublished.
    Tom · 2 years ago
    How can I change the password to another value?
  • To post as a guest, your comment is unpublished.
    Tom · 2 years ago
    Has it been asked / answered? Where in the code can you specify / change a personal password?
  • To post as a guest, your comment is unpublished.
    Emmanuel Nyemah · 3 years ago
    Hello, please help me expand and collapse rolls and collumns in excel spreadsheet that is protected. I tried using the ones you showed above but they do not work.
  • To post as a guest, your comment is unpublished.
    Emmanuel Nyemah · 3 years ago
    Please help me, I want to collapse and expand some rolls and collumns in an excel spreadsheet that is protected. How can I use macros to do this? I have tried what you showed but they just don't work on my spreadsheet. Please help.
  • To post as a guest, your comment is unpublished.
    Steph · 4 years ago
    Hello! I used the first macro with success and then had the same issue of closing the workbook and the macro no longer working. I see the solution above but cannot get that to work at all. Would you mind stepping me through? Do I combine both codes or just use the latter? If my password is "dog" do I replace one of the values in the code? I am only applying to one worksheet ("Sheet1"); do I use that anywhere? Many thanks in advance!!
  • To post as a guest, your comment is unpublished.
    Chiu · 4 years ago
    Private Sub Workbook_Open()
    Dim wsh As Variant
    For Each wsh In Worksheets(Array("TD_ phase_3", "RS_Phase_2"))
    wsh.EnableOutlining = True
    wsh.Protect Password:="260615", DrawingObjects:=False, _
    contents:=True, _
    Scenarios:=True, _
    AllowFiltering:=True, _
    AllowFormattingCells:=True, _
    userinterfaceonly:=True
    Next wsh
    End Sub
    • To post as a guest, your comment is unpublished.
      Josh · 2 years ago
      Can you do a step by step walk thru as to where to put this as they did in the original instructions. Thank you.
    • To post as a guest, your comment is unpublished.
      jgarner · 2 years ago
      Still not sure how this works. Do i make a new module or attach to the one above?
  • To post as a guest, your comment is unpublished.
    Phi Bach · 4 years ago
    I have the same problem when i close the workbook. Any ideas to fix it?
  • To post as a guest, your comment is unpublished.
    Nauman · 5 years ago
    Thank you so much bro this works really nice.Thanks alot
    • To post as a guest, your comment is unpublished.
      jgarner · 2 years ago
      How did you get this to work? I've tried adding it to the VBA above and making a different module but it still doesnt work. Do i need to change any of the codes? like my password i am using or do i need to change the sheet names?
  • To post as a guest, your comment is unpublished.
    mayich · 5 years ago
    This seems to work great, but when I close and re-open the workbook, I run into the same problem - I cannot expand my collapsed groups.
    • To post as a guest, your comment is unpublished.
      Chiu · 4 years ago
      [quote name="mayich"]This seems to work great, but when I close and re-open the workbook, I run into the same problem - I cannot expand my collapsed groups.[/quote]That matter is solved as bellow
      Private Sub Workbook_Open()
      Dim wsh As Variant
      For Each wsh In Worksheets(Array("Sheet1", "Sheet2"))
      wsh.EnableOutlining = True
      wsh.Protect Password:="260615", DrawingObjects:=False, _
      contents:=True, _
      Scenarios:=True, _
      AllowFiltering:=True, _
      AllowFormattingCells:=True, _
      userinterfaceonly:=True
      Next wsh
      End Sub
      • To post as a guest, your comment is unpublished.
        Morne · 2 years ago
        I got the same problem, as soon as I close and re-enter sheet, it doesn't work... please give step by step of where and how to use
        That matter is solved as bellow
        Private Sub Workbook_Open()
        Dim wsh As Variant
        For Each wsh In Worksheets(Arra y("Sheet1", "Sheet2"))
        wsh.EnableOutli ning = True
        wsh.Protect Password:="2606 15", DrawingObjects: =False, _
        contents:=True, _
        Scenarios:=True, _
        AllowFiltering:=True, _
        AllowFormattingCells:=True, _
        userinterfaceonly:=True
        Next wsh
        End Sub
    • To post as a guest, your comment is unpublished.
      Romi · 5 years ago
      I have the same problem, does anyone know how to overcome it.

      Many thanks