Excel's 'undo' function by using vba? How to only undo certain cells

dshervin1

New Member
Joined
Jan 4, 2013
Messages
4
I have the following VBA code inserted into my spreadsheet:

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("c12:c45")) Is Nothing Then
With Application
.EnableEvents = False
.Undo
.EnableEvents = True
End With
End If
End Sub

The macro works excellent, except for the fact that if I delete an entire row such as row 12, and I want everything in row 12 to be deleted except for c12, it undos the entire deletion. I was wondering if there was a way to manipulate this code to only undo the actions taken on the cells c12:c45. Thank you so much in advance to anyone that wants to try and help me. I will appreciate it greatly!!!!!!!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top