VBA code speed Shared workbook

Isabella

Well-known Member
Joined
Nov 7, 2008
Messages
643
Hi the below code takes 6-7 seconds to run, is there anything i can do to make it faster?

Code:
Private Sub CommandButton5_Click()

With Application
    .DisplayAlerts = False
    .ScreenUpdating = False
   .Calculation = xlCalculationManual
End With

'Unshare workbook
If ThisWorkbook.MultiUserEditing Then
   ThisWorkbook.ExclusiveAccess
End If

If ActiveSheet.FilterMode Then
    ActiveSheet.ShowAllData
End If

'Share workbook
ThisWorkbook.SaveAs ThisWorkbook.FullName, accessmode:=xlShared

With Application
    .DisplayAlerts = True
    .ScreenUpdating = True
    .Calculation = xlAutomatic
End With

End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
There is probably not a way to make it any faster because when you unshare and share the workbook, it has to save each time. So depending on how big your file is will determine how long it takes for the code to run. So really, the only way to make it "run faster" is to reduce the size of your workbook.
 
Upvote 0
There is probably not a way to make it any faster because when you unshare and share the workbook, it has to save each time. So depending on how big your file is will determine how long it takes for the code to run. So really, the only way to make it "run faster" is to reduce the size of your workbook.

My workbook is only 368kb, not big at all
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,839
Members
452,948
Latest member
UsmanAli786

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