The Undo buton will have no effect for the changes made by the macro, unless you use some macro codes.
Here is a sample code to restore the changes made by the macro (EditRange). Just select a range on your worksheet and run the macro (EditRange).
Sub EditRange()
Dim i As Integer, cl As Range
If TypeName(Selection) <> "Range" Then Exit Sub
Application.ScreenUpdating = False
ReDim OrgCells(Selection.Count)
Set OrgWB = ActiveWorkbook
Set OrgWS = ActiveSheet
i = 1
For Each cl In Selection
OrgCells(i).CellContent = cl.Formula
OrgCells(i).CellAddress = cl.Address
i = i + 1
Next cl
Selection.Formula = "The selected cells have been filled by the macro, now you can click the Undo button to restore !"
Application.OnUndo "Undo the latest macro", "UndoEditRange"
End Sub
Sub UndoEditRange()
Dim i As Integer
Application.ScreenUpdating = False
On Error GoTo NoWBorWS
OrgWB.Activate
OrgWS.Activate
On Error GoTo 0
For i = 1 To UBound(OrgCells)
Range(OrgCells(i).CellAddress).Formula = OrgCells(i).CellContent
Next i
Set OrgWB = Nothing
Set OrgWS = Nothing
Erase OrgCells
NoWBorWS:
End Sub