Repairs to XLSB workbook

Billdub417

New Member
Joined
Nov 5, 2019
Messages
45
Hello,

Glad of any advice..
I have a workbook with quite a lot of code in....

Sometime when I open it, it is randomly coming up as read only and the below repair...

Any thoughts on why this might be happening and how to stop it going forward?

thanks,


1613404713084.png
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Sounds like you have code that sorts the 3rd sheet in the workbook & that you are not deleting existing sortfields before adding the new ones.
 
Upvote 0
Yes it does.
The only thing i can see is a macro that affects this sheet as below:

Would this be causing it? If so, what would needs adding to delete sortfield?

VBA Code:
Sub Update()
With Sheets("sh3")
With .Sort
        .SortFields.Add Key:=Range("A1"), Order:=xlAscending
         .SetRange Sheet1.Range("A1:C1000")
         .Header = xlYes
         .Apply
        End With
End With

End Sub
 
Upvote 0
Yup, that's the culprit, add this line as shown
VBA Code:
With .Sort
        .SortFields.Clear
        .SortFields.Add Key:=Range("A1"), Order:=xlAscending
 
Upvote 0
Solution
Yup, that's the culprit, add this line as shown
VBA Code:
With .Sort
        .SortFields.Clear
        .SortFields.Add Key:=Range("A1"), Order:=xlAscending
Perfecto! Thanks so much, you wouldn't realise how annoying that has been !!! :D
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,509
Members
448,967
Latest member
screechyboy79

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