Ir para o conteúdo principal

Como controlar as alterações sem compartilhar a pasta de trabalho?

Normalmente, quando você aplica o recurso Controlar alterações no Excel, a pasta de trabalho será compartilhada ao mesmo tempo, o que será irritante porque alguns dos recursos do Excel serão desabilitados. Como você poderia controlar as alterações sem compartilhar a pasta de trabalho? Aqui, vou recomendar um código VBA para você.

Rastreie as alterações sem compartilhar a pasta de trabalho com o código VBA


seta azul bolha direita Converter texto em tabela no Outlook

Não há uma maneira direta de resolver esse problema, mas você pode aplicar um código VBA flexível para resolvê-lo. Faça o seguinte:

1. Clique com o botão direito na guia da planilha que deseja controlar as células alteradas e escolha Ver código a partir do menu de contexto, no pop-out Microsoft Visual Basic para Aplicações janela, copie e cole o código a seguir no espaço em branco Módulo:

Código VBA: rastreie as alterações sem compartilhar a pasta de trabalho:

Private Sub Worksheet_Change(ByVal Target As Range)
  'Updateby Extendoffice
    Const xRg As String = "A1:Z1000"
    Dim strOld As String
    Dim strNew As String
    Dim strCmt As String
    Dim xLen As Long
    With Target(1)
        If Intersect(.Cells, Range(xRg)) Is Nothing Then Exit Sub
        strNew = .Text
        Application.EnableEvents = False
        Application.Undo
        strOld = .Text
        .Value = strNew
        Application.EnableEvents = True
        strCmt = "Edit: " & Format$(Now, "dd Mmm YYYY hh:nn:ss") & " by " & _
        Application.UserName & Chr(10) & "Previous Text :- " & strOld
        If Target(1).Comment Is Nothing Then
            .AddComment
        Else
            xLen = Len(.Comment.Shape.TextFrame.Characters.Text)
        End If
        With .Comment.Shape.TextFrame
            .AutoSize = True
            .Characters(Start:=xLen + 1).Insert IIf(xLen, vbLf, "") & strCmt
        End With
    End With
End Sub

doc trilha mudança sem compartilhar 1

Note: No código acima, A1: Z1000 é o intervalo de dados que você deseja controlar as alterações.

2. Em seguida, salve e feche esta janela de código, agora, quando você alterar os valores em qualquer célula dentro do intervalo especificado definido no código, as células serão rastreadas e a pasta de trabalho não será compartilhada. Veja a imagem:

doc trilha mudança sem compartilhar 2

Melhores ferramentas de produtividade de escritório

🤖 Assistente de IA do Kutools: Revolucionar a análise de dados com base em: Execução Inteligente   |  Gerar Código  |  Crie fórmulas personalizadas  |  Analise dados e gere gráficos  |  Invocar funções do Kutools...
Recursos mais comuns: Encontre, destaque ou identifique duplicatas   |  Excluir linhas em branco   |  Combine colunas ou células sem perder dados   |   Rodada sem Fórmula ...
Super pesquisa: VLookup de múltiplos critérios    VLookup de múltiplos valores  |   VLookup em várias planilhas   |   Pesquisa Difusa ....
Lista suspensa avançada: Crie rapidamente uma lista suspensa   |  Lista suspensa de dependentes   |  Lista suspensa de seleção múltipla ....
Gerenciador de colunas: Adicione um número específico de colunas  |  Mover colunas  |  Alternar status de visibilidade de colunas ocultas  |  Compare intervalos e colunas ...
Recursos em destaque: Foco da Grade   |  Vista de Design   |   Grande Barra de Fórmula    Gerenciador de pastas de trabalho e planilhas   |  Biblioteca (Auto texto)   |  Data Picker   |  Combinar planilhas   |  Criptografar/Descriptografar Células    Enviar e-mails por lista   |  Super Filtro   |   Filtro Especial (filtro negrito/itálico/tachado...) ...
15 principais conjuntos de ferramentas12 Texto Ferramentas (Adicionar texto, Remover Personagens, ...)   |   50+ de cores Tipos (Gráfico de Gantt, ...)   |   Mais de 40 práticos Fórmulas (Calcule a idade com base no aniversário, ...)   |   19 Inclusão Ferramentas (Insira o código QR, Inserir imagem do caminho, ...)   |   12 Conversão Ferramentas (Números para Palavras, Conversão de moedas, ...)   |   7 Unir e dividir Ferramentas (Combinar linhas avançadas, Dividir células, ...)   |   ... e mais

Aprimore suas habilidades de Excel com o Kutools para Excel e experimente uma eficiência como nunca antes. Kutools para Excel oferece mais de 300 recursos avançados para aumentar a produtividade e economizar tempo.  Clique aqui para obter o recurso que você mais precisa...

Descrição


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

  • Habilite a edição e leitura com guias em 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!
Comments (14)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Does this MAcro capture changes on formula values everytime my data model is updated?
This comment was minimized by the moderator on the site
Is there a way to record the changes for all tabs in a workbook, and record the changes to a new spreadsheet? THAT would be awesome ... and I can't find any information across the internet with this type of tracking process.
This comment was minimized by the moderator on the site
Hello, jfjoyner,To change this code for all sheets, and record the track changes to another sheet, please use the below code:
Note: Please put this code into the ThisWorkbook module.
Option Explicit
Dim mStrRgAddress As String
Dim mStrRgValue As String

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Const xRg As String = "A1:Z1000"
Const xSheetName As String = "Record sheet" 'The sheet that you want to put the track changes, please change the sheet name to your own.
Dim strOld As String
Dim strNew As String
Dim strCmt As String
Dim xLen As Long
Dim xSheet As Worksheet
Dim xRgCell As Range
Dim xRgCell2 As Range
On Error Resume Next
Set xSheet = Application.Sheets.Item(xSheetName)
If mStrRgAddress <> "" Then
Set xRgCell = Range(mStrRgAddress)
If xRgCell.Text <> mStrRgValue Then
strCmt = mStrRgAddress & " : " & Format$(Now, "dd Mmm YYYY hh:nn:ss") & " by " & _
Application.UserName & Chr(10) & "Previous Text :- " & mStrRgValue
Set xRgCell2 = xSheet.Range("a1048576").End(xlUp)
If xRgCell2.AddressLocal = xSheet.Range("A1").AddressLocal Then
If xRgCell2.Value <> "" Then
Set xRgCell2 = xRgCell2.Offset(1, 0)
End If
Else
Set xRgCell2 = xRgCell2.Offset(1, 0)
End If
xRgCell2.Value = strCmt
End If
End If
If xSheet.Name = Sh.Name Then Exit Sub
mStrRgValue = Target.Text
mStrRgAddress = Target.AddressLocal(False, False, , True)
End Sub
This comment was minimized by the moderator on the site
Thanks, this is great, but I can't get it to work. I assume it runs automatically, meaning no need to click on "Run"? I renamed a worksheet to say {--TRACK_CHANGES--} to follow the instructions you left in green. So far, it is not recording anything. Thanks.
This comment was minimized by the moderator on the site
Hello jfjoyner3,First, after you copy our VBA Code into the ThisWorkbook module, the code runs automatically.Second, our VBA code does works. Plesae see the two screenshots I uploaded in this comment.
This comment was minimized by the moderator on the site
Mandyzhou, Thank you again for this detailed guidance. I am getting a Syntax Error and it points me to this line:

If mStrRgAddress <> "" Then

Are you able to guide to modify this and remove the Syntax Error?
Thank you!
This comment was minimized by the moderator on the site
Thanks again, skyyang.I also noticed that when I pasted this into the module for This Workbook, my large spreadsheet began to calculate continuously and would not stop.  I know nothing about VBA programming, but I found this discussion about the same topic. It might explain why the calculation goes on endlessly. https://www.mrexcel.com/board/threads/continuous-calculation-wont-stop.1179541/page-6#posts 
The issue on this web site was: <span style="letter-spacing: 0.2px; color: inherit; font-family: inherit; font-style: inherit; font-variant-ligatures: inherit; font-variant-caps: inherit;">But once the continuous-calculation issue starts, it's persistent. Pressing the Esc key does interrupt the calculation, but it starts right back up again unless I switch to Manual Calc. Manual calc mode works fine until I run any of the macros, which then ends by re-enabling AutoCalc... I've been through each worksheet in the model and run error-checking to no avail.</span>
Their conclusion was: This is true: once you refer to a form object or its property (frmBudget.startupposition = 3) - the object is then loaded until you unload it or reset your project (State loss - At this point ALL variables are reset and any values lost)
This comment was minimized by the moderator on the site
Hello jfjoyner3,How are you. As you can see in the two screenshots, I changed the "record sheet" into "sheet2" in the VBA Code. 
Then I returned to Excel workbook. After I made some changes in the sheet1, all these changes are recorded in the sheet2.
As for the continuous-calculation issue, could you please send us the screenshots or video of your problem? So we can fully understand what is going on here. Thanks! 
Sincerely,Mandy
This comment was minimized by the moderator on the site
MandyZhou, thank you. Does this macro start automatically when I open the spreadsheet? Or must I start it manually? 
The continuous calculation problem is related to another app. 
This comment was minimized by the moderator on the site
Thank you very much!
This comment was minimized by the moderator on the site
Hello jfjoyner3,You are welcome. After you save the spreadsheet with the macro VBA code, the macro will start automatically every time you open the spreadsheet. No need to start it manually. Any question, please feel free to contact us. Have a nice day!Best regards,Mandy   
This comment was minimized by the moderator on the site
I tried using this VBA code in my excel sheet. But it gave me errors. I don't know from where this macro should be called and what is the argument to the function you have provided when it is called.
This comment was minimized by the moderator on the site
Great work. Unfortunately, there are some issues with your code. - It will add a comment even on the first entry of the cell. How can I make it track changes from the second entry not the first one? - Once I enter a value in a cell I can't do "Undo". - It doesn't work with tables. Try to use on a table then try to add or delete a raw and the code will crash. I really wish I have the knowledge to get the code to work the way I want it as described above.
This comment was minimized by the moderator on the site
I have the same issue. "Undo" and "Redo" buttons don't work anymore. Is there any solution for this?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations