Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
publicado

Buenas a tod@s siempre he dado por sentado que realizar la restauración de una modificación de datos por parte de la ejecución de una macro era posible pero a la vez harto dificil por lo que revisando y nevegando he localizado el siguiente codigo que realiza dicha labor es decir dar la opción de deshacer ;con el menu deshacer lo realizado, por una macro restaurando los datos que hubiese antes de ser ejecutada

el aporte es de la pagina http://spreadsheetpage.com/index.php/tip/C32

y el codigo

 
Option Explicit
Type SaveRange
Val As Variant
Addr As String
End Type

Public OldWorkbook As Workbook
Public OldSheet As Worksheet
Public OldSelection() As SaveRange
'------------------------------------------------------------------------------
Sub Cambio()
Dim i
Dim cell


If TypeName(Selection) <> "Range" Then Exit Sub

'Guarda los valores actuales para deshacer
ReDim OldSelection(Selection.Count)
Set OldWorkbook = ActiveWorkbook
Set OldSheet = ActiveSheet
i = 0
For Each cell In Selection
i = i + 1
OldSelection(i).Addr = cell.Address
OldSelection(i).Val = cell.Formula
Next cell

'Insertar 0 en la selección actual
Application.ScreenUpdating = False
Selection.Value = 0

'Especificar el nombre que aparecera en menu Deshacer
Application.OnUndo "Deshacer macro", "Deshacermacro"
End Sub
'--------------------------------------------------------------------------------
Sub Deshacermacro()
Dim i
' "Deshace el efecto de la macro
On Error GoTo Problem
Application.ScreenUpdating = False

OldWorkbook.Activate
OldSheet.Activate

' Restaurar la información guardada
For i = 1 To UBound(OldSelection)
Range(OldSelection(i).Addr).Formula = OldSelection(i).Val
Next i
Exit Sub

Problem:
MsgBox "No se puede deshacer"
End Sub
[/CODE]

un saludo

Featured Replies

publicado

Gracias por el aporte Logroastur.

Saludos.

Crear una cuenta o conéctate para comentar

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.