undo button not working

jrisebo

Active Member
Joined
Mar 15, 2011
Messages
310
Office Version
  1. 365
Platform
  1. Windows
when I do something, then go on to something else, the undo button isnt working. I have read that it could be VBA causing this, how do I find out which one, and correct?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Any VBA code will clear the undo stack when it is run.

But if im just typing in a cell, press enter, what VBA code is running, or does it run everytime i press enter. Other spreadsheets seem to not do this, and have vba code in them.
 
Upvote 0
Perhaps you have event code. Right click the sheet tab and select View Code. Is there any code?
 
Upvote 0
Perhaps you have event code. Right click the sheet tab and select View Code. Is there any code?

Yes, alot of code stuff. I didnt create this spreadsheet, just modifying. Its only this tab, others it works. How do I know which part of the code is doing it?:confused:
 
Upvote 0
Can you copy the code and paste it here.

yes



Private Sub CBBanchattach_Click()

End Sub

Private Sub CheckBox1_Click()

End Sub

Private Sub CMPrint_Click()
If CBInput.Value = True Then
Sheets("INPUT").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBA1.Value = True Then
Sheets("I. A1").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBA2.Value = True Then
Sheets("I. A2").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBA3.Value = True Then
Sheets("I. A3").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBA4.Value = True Then
Sheets("I. A4").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBA5.Value = True Then
Sheets("I. A5").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBCG.Value = True Then
Sheets("CG").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CB2Plate.Value = True Then
Sheets("II. 2 plate").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CB3Plate.Value = True Then
Sheets("II. 3 plate").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBBearing.Value = True Then
Sheets("III. bearing").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBFtgBending.Value = True Then
Sheets("IV. ftg bending").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBFtgBending = True Then
Sheets("V. bending (V bars)").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBAanchattach = True Then
Sheets("VI. A anch attach").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBBanchattach = True Then
Sheets("VI. B anch attach").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBCanchattach = True Then
Sheets("VI. C anch attach").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBDanchattach = True Then
Sheets("VI. D anch attach").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBEanchattach = True Then
Sheets("VI. E anch attach").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBRichmond = True Then
Sheets("Richmond Inserts Capacity").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBEffective = True Then
Sheets("Effective Slope").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
If CBPlateCalc = True Then
Sheets("3plate-calcs").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
Sheets("INPUT").Select
End Sub

Private Sub CheckBox2_Click()

End Sub

Private Sub CheckBox3_Click()

End Sub

Private Sub ComboBox1_Change()

End Sub

Private Sub CommandButton1_Click()
Dim Off As Integer
Application.EnableEvents = False
Select Case Range("Wingwall_Number").Value
Case 1
Off = 0
Case 2
Off = 26
Case 3
Off = 51
Case 4
Off = 76
End Select
If WorkbookIsOpen(FileNameOnly(Range("sourcefile").Text)) = False Then
Workbooks.Open Filename:=Range("sourcefile").Text
End If
Windows(FileNameOnly(Range("sourcefile").Text)).Activate
Sheets("Summary").Activate

ActiveSheet.Range("WW1TypeA").Offset(Off + 12, 0) = Range("$b$84")
ActiveSheet.Range("WW1TypeA").Offset(Off, 0) = Range("as")
ActiveSheet.Range("WW1TypeA").Offset(Off + 1, 0) = Range("bs")
ActiveSheet.Range("WW1TypeA").Offset(Off + 2, 0) = Range("cs")
ActiveSheet.Range("WW1TypeA").Offset(Off + 3, 0) = Range("ds")
ActiveSheet.Range("WW1TypeA").Offset(Off + 4, 0) = Range("es")
ActiveSheet.Range("WW1TypeA").Offset(Off + 7, 0) = Range("$b$95") * 12
ActiveSheet.Range("WW1TypeA").Offset(Off + 8, 0) = Range("$b$96")
ActiveSheet.Range("WW1TypeA").Offset(Off + 9, 0) = Range("$b$97")
ActiveSheet.Range("WW1TypeA").Offset(Off + 11, 0) = Range("$b$94")
ActiveSheet.Range("WW1TypeA").Offset(Off + 10, 0) = Range("dist1")
Application.EnableEvents = True
End Sub

Private Sub ListBox1_Click()

End Sub

Private Sub ComboBox3_Change()

End Sub

Private Sub ToggleButton1_Click()

End Sub



Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next

Dim WW_Template As Workbook
Set WW_Template = Application.ActiveWorkbook

Dim InputSheet As Worksheet
Set InputSheet = WW_Template.Worksheets("INPUT")

Dim SampleSheet As Worksheet
Set SampleSheet = WW_Template.Worksheets("Sample")

Dim Sh As Shape
For Each Sh In SampleSheet.Shapes
Sh.Delete
Next Sh

GenerateViews
End Sub
 
Upvote 0
It is this which runs every time you select a cell

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
        
    Dim WW_Template As Workbook
    Set WW_Template = Application.ActiveWorkbook
    
    Dim InputSheet As Worksheet
    Set InputSheet = WW_Template.Worksheets("INPUT")
    
    Dim SampleSheet As Worksheet
    Set SampleSheet = WW_Template.Worksheets("Sample")

    Dim Sh As Shape
    For Each Sh In SampleSheet.Shapes
        Sh.Delete
    Next Sh

GenerateViews
End Sub

As far as I can see that deletes all the shapes from (another?) sheet every time you change the selection. I cannot imagine the purpose of that.
 
Upvote 0
It is this which runs every time you select a cell

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
        
    Dim WW_Template As Workbook
    Set WW_Template = Application.ActiveWorkbook
    
    Dim InputSheet As Worksheet
    Set InputSheet = WW_Template.Worksheets("INPUT")
    
    Dim SampleSheet As Worksheet
    Set SampleSheet = WW_Template.Worksheets("Sample")

    Dim Sh As Shape
    For Each Sh In SampleSheet.Shapes
        Sh.Delete
    Next Sh

GenerateViews
End Sub
As far as I can see that deletes all the shapes from (another?) sheet every time you change the selection. I cannot imagine the purpose of that.

Based on the input on this sheet, it draws a picture of the inputs. If you change something on the input screen, it deletes what it had, to redraw with out the old lines. that make sense? is there a better way to do this?
 
Upvote 0
If you change it to

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
        
    Dim WW_Template As Workbook
    Set WW_Template = Application.ActiveWorkbook
    
    Dim InputSheet As Worksheet
    Set InputSheet = WW_Template.Worksheets("INPUT")
    
    Dim SampleSheet As Worksheet
    Set SampleSheet = WW_Template.Worksheets("Sample")

    Dim Sh As Shape
    For Each Sh In SampleSheet.Shapes
        Sh.Delete
    Next Sh

GenerateViews
End Sub

It will only run when you change a value. Entering data will still cause the undo stack to be cleared.
 
Upvote 0

Forum statistics

Threads
1,213,552
Messages
6,114,278
Members
448,560
Latest member
Torchwood72

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