The macro works perfectly on mine Excel365 but it crashes when my colleague runs it on his computer (also Excel365). Can you please tell me what I'm doing wrong? I'd like to provide the tool working for everyone.
Here's problematic fragment of the code.
'Optimalization activated
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayStatusBar = False
On Error GoTo ErrorHandler
Dim myValue As String
Dim wb As Workbook
'Welcome Prompt/clipboard thingy
MS = "Hello! Before we start, please prepare Customer ID. We'll need it later" & vbNewLine & vbNewLine
MS = MS & "CLICK ON THE 'OK' BUTTON ONCE COPIED"
MsgBox MS, vbOKOnly, "Welcome - let's prepare Customer ID"
'New excel
Workbooks.Add
Set wb = ActiveWorkbook
'Data from server - copy & close
Workbooks.Open ("\\THE_FILE_FROM_SERVER.xlsx")
Workbooks("THE_FILE_FROM_SERVER").Sheets("Sheet1").Activate
Sheets("Sheet1").Cells.Copy Destination:=wb.Sheets("Sheet1").Range("A1")
Workbooks("THE_FILE_FROM_SERVER.XLSX").Close SaveChanges:=False
'New Workbook magic
wb.Sheets("Sheet1").Activate
'Column cleanup
Columns("A:C").Select
Selection.Delete Shift:=xlToLeft
Columns("C:E").Select
Selection.Delete Shift:=xlToLeft
Columns("D:F").Select
Selection.Delete Shift:=xlToLeft
Columns("K:K").Select
Selection.Delete Shift:=xlToLeft
Columns("L:Y").Select
Selection.Delete Shift:=xlToLeft
Columns("M:R").Select
Selection.Delete Shift:=xlToLeft
Columns("N:AT").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
'Borders added
Columns("A:M").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Rows("1:1").Select
Selection.AutoFilter
Range("A1").Select
'Top row freeze
wb.Sheets("Sheet1").Activate
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With
ActiveWindow.FreezePanes = True
'Renaming
wb.Sheets("Sheet1").Activate
ActiveSheet.Name = "Open Orders Status" & " " & Format(Date, "yyyy/mm/dd")
The moment it crashes only on some Excels:
'Top row freeze
wb.Sheets("Sheet1").Activate
Thank you in advance for taking a time to review my lines.