Macro stopped working - no longer selects worksheet

luvofgreen

New Member
Joined
Oct 9, 2009
Messages
1
First time poster. If you need any additional information let me know. Difficult to google issue. Hoping for some guidance.

Running in Excel 365 on Win10. Code has been working for at least 3 years. Stopped working 2 weeks ago after HR person said her Excel kept on hanging. Determined there was a firewall issue causing the ODBC call within the program was being blocked and gave the appearance of hanging while waiting for a timeout. Fixed that issue. Because of the constant killing of Excel, figured the the data file (Employee Change) became corrupt, so I rebuilt a new one from scratch, copying each tab to a new file, thankfully started working again. The Employee Change file stopped working again today, but was used by a different HR person, different machine. Remoted into that HR's machine and didn't see any issues as file closed properly multiple attempts. Rebuilt the file again, no luck.

SCENARIO
I have a main Excel file (Orientation.xlsm refer to as O) that calls another file (Employee Change.xlsm refer to as EC), it gets the last used row in a worksheet and gathers the rows of applicable data in EC and then writes that data to a worksheet in O. Closes and saves EC. This has been working great for 3 years

Today, when O closes EC, there is Workbook_BeforeSave code that no longer works. Call from O is below, WkbkS2 references Employee Change

Code from O
VBA Code:
WbkS2.Activate

'Worksheets("Sheet1").Select   'Test to see where code stops working this works
WbkS2.Close SaveChanges:=True

Code in EC
VBA Code:
Sub Workbook_BeforeClose(Cancel As Boolean)

'Dim x As Variant
    x = MsgBox("Are you sure you want to quit?" & Chr(10) & Chr(13) & "Once closed updates will be sent to IS Account Management. ", vbYesNo)
    If x = vbYes Then
        Application.ScreenUpdating = True
        ActiveWorkbook.Worksheets("Sheet1").Select    'Test to see where code stops working which is in here
        Call SendUpdatesWhenClosing(Row, SR)
        ThisWorkbook.Save
    Else
        Cancel = True
    End If
End Sub

Any attempt to switch worksheets or select any cells fails to update in Workbook_BeforeClose section of code. I have code that follows that selects the last used cells on the worksheet and it returns row 1 because the correct worksheets does NOT get selected. Any help or guidance to resolve this headache will be greatly appreciated.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi luvofgreen and Welcome to the Board! Maybe give these a whirl...
Code:
WbkS2.Save
WbkS2.Close
or....
Code:
Application.DisplayAlerts = False
WbkS2.SaveAs "YourFullPath", FileFormat := 51
WbkS2.Close 
Application.DisplayAlerts = True
HTH. Dave
 
Upvote 0

Forum statistics

Threads
1,215,635
Messages
6,125,945
Members
449,275
Latest member
jacob_mcbride

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