Name

workbook.AcceptAllChanges([When], [Who], [Where])

Synopsis

For shared workbooks, commits the changes to the workbook.

Argument

Settings

When

A string indicating the time after which to accept changes

Who

A string indicating the user from which to accept changes

Where

A string indicating a range of cells for which to accept changes

It’s easiest to see the effect of AcceptAllChanges when you combine it with RejectAllChanges. For example, the following code accepts all of the changes made to the range A2:D4, but rejects changes to other cells if they were made within the last minute:

If ThisWorkbook.MultiUserEditing Then
    [a1] = "Value rejected": [b2] = "Value kept"
    ThisWorkbook.AcceptAllChanges , , "$A$2:$D$4"
    ' Reject other changes made in the last minute.
    ThisWorkbook.RejectAllChanges CStr(Now - 0.001)
End If

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.