Sort Error on open

Evapar18

Board Regular
Joined
Aug 3, 2018
Messages
86
Office Version
  1. 2019
Platform
  1. Windows
Recently I added the code below to do some auto sorting with a button. It works great and I don't recall any problems after I first made it (couple weeks ago). Now when I open the file, use the sort button, save it close it and reopen the file, it prompts me to repair the file. If I save the file without using the button it does not prompt me with an error.

I don't understand what this error message means, much less how to fix it.

Code:
Code:
Private Sub CommandButton1_Click()

With ActiveSheet.Sort
     
     .SortFields.Add Key:=Range("N8"), Order:=xlDescending
     .SortFields.Add Key:=Range("D8"), Order:=xlAscending
     .SetRange Range("C8:N250")
     .Header = xlYes
     .Apply
  
End With


ActiveSheet.ListObjects("Table3").Range.AutoFilter Field:=13, Criteria1:= _
        "1"


End Sub

Error log:
PHP:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error109640_01.xml</logFileName><summary>Errors were detected in file 'C:\Users\scott.baugh\Documents\GEASWUG\GEASWUG ALL Contacts_Registration.xlsm'</summary><removedRecords><removedRecord>Removed Records: Sorting from /xl/worksheets/sheet2.xml part</removedRecord></removedRecords></recoveryLog>
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try
Code:
With ActiveSheet.Sort
     [COLOR=#ff0000].SortFields.Clear[/COLOR]
     .SortFields.Add Key:=Range("N8"), Order:=xlDescending
     .SortFields.Add Key:=Range("D8"), Order:=xlAscending
     .SetRange Range("C8:N250")
     .Header = xlYes
     .Apply
  
End With
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,536
Members
449,037
Latest member
tmmotairi

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