VBA Macro not working after move form 2010 to 2016

kenderweasel

New Member
Joined
Feb 17, 2017
Messages
40
Hi,

I've got a problem with a macro on one of my worksheets not working since I moved from Excel 2010 to 2016 this morning. The macro is designed to auto-sort data by column F:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("F:F")) Is Nothing Then
Range("F1").Sort Key1:=Range("F2"), _
Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub

Thanks!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Is it giving you an error? I just tried the code in Excel 2016, and it works without error.
 
Upvote 0
No time wasted! :)

What likely happened is your Events got disabled by another macro. If this happens again, try going into the VBA editor's Immediate Window and entering Application.EnableEvents = True.
 
Upvote 0
Hi,

Apologies - I thought this had resolved itself, but it's not working. What happens is that the column is auto-sorted on first opening the document, but changes to unsorted once the file has finished its calculations. I've tried inputing Application.EnableEvents=True into the Immediate Window, but it's still not working.
 
Upvote 0
Is there a workbook_open() event in your VBA? If so, please post the entire code.
 
Upvote 0
Try dropping this into that same worksheet's code module.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Application.StatusBar = "You have selected cell" _
                          & IIf(Target.Count > 1, "s ", " ") _
                          & Target.Address(0, 0)
End Sub
Is the status bar updating as you select different cells on the worksheet?

Just delete (or comment out) the code and type application.statusbar = false in the immediate window to reset your statusbar once you've done the test.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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