'VBA Excel not working after saving and reopening
I have a code that I was trying to use to sort some content at work. The code is as follows:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("A:A")) Is Nothing Then
Range("H2").Sort Key1:=Range("A2"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub
It works great when I first put it in and add some dates to the A column in my .xlsx file, however, after I saved it as an .xlsm file and reopened it, the program no longer did anything. Whats going on and how can I get it to work again? My coworkers aren't savvy enough to reenter this every time and I really just want it to sort anytime someone enters the date. How can I get this program to work any time someone enters the data? I've tried it in Module and in Sheet1 and no beans
EDIT Working again, No clue Why. Just reopened the program a few times and it worked. I had the program in a module in an xlsm file (The one not working originally @findwindow) and in Sheet1 (Just to cover all my bases). As for what the code is supposed to do, its supposed to sort the date entered (Column A) while maintaining the row integrity to Column H (Which it does well when it works). For Example, if I enter 5/24/2022 Joe ID8 NK BLANK Signed by NK then the entire row of content will be sorted to the space where 5/24/2022 would go chronologically. This is done automatically so that my coworkers don't need to constantly push sort (Which I've also had issues getting to sort correctly).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
