tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,194
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I have this macro that is supposed to delete the active sheet, select the welcome sheet and remove that sheets details from the sheet list in clumn Q to S
It works great then suddenly i get this message:
Run time error '-2147417848(8001010)
Automation error
The object invoked has disconnected from its clients
this is my code: if anyone can improve it and make it work without crashing this would be great
Thanks
Tony
I have this macro that is supposed to delete the active sheet, select the welcome sheet and remove that sheets details from the sheet list in clumn Q to S
It works great then suddenly i get this message:
Run time error '-2147417848(8001010)
Automation error
The object invoked has disconnected from its clients
this is my code: if anyone can improve it and make it work without crashing this would be great
VBA Code:
Sub Delete()
Application.EnableEvents = False
Application.ScreenUpdating = False
WsName = ActiveSheet.Name
Sheets(WsName).Delete
Sheets("Welcome").Unprotect Password:="august"
Sheets("Welcome").Select
Sheets("Welcome").Columns("Q").Find(WsName, , xlValues, xlWhole, xlByRows, xlNext).Resize(, 3).ClearContents
Sheets("Welcome").Sort.SortFields.Clear
Sheets("Welcome").Sort.SortFields.Add2 Key:=Range( _
"S11:S29"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With Sheets("Welcome").Sort
.SetRange Range("Q11:S29")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Sheets("Welcome").Sort.SortFields.Clear
Sheets("Welcome").Protect Password:="august"
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Thanks
Tony