Forum Discussion
seanrm100_
Sep 27, 2019Copper Contributor
Mystery error happens randomly, but more often when running from a formcontrol button...
So I have a macro that creates sheets, transfers data to them, and then cleans it. All is well and good, but I often get the 'Runtime Error 1004: The sort reference isn't valid. Make sure that it'...
- Sep 28, 2019
You should qualify the key with the Sheet reference like this...
ws.Range("A1:Z200").Sort Key1:=ws.Columns("A"), Order1:=xlAscending, Header:=xlNoOr more precisely this...
ws.Range("A1:Z200").Sort Key1:=ws.Range("A1"), Order1:=xlAscending, Header:=xlNoThis should resolve the issue.
seanrm100_
Sep 30, 2019Copper Contributor
Wow, that's what I get for copying and pasting code, I can't believe I've been I've been dealing with this for weeks over something so silly. Thanks!
Subodh_Tiwari_sktneer
Sep 30, 2019Silver Contributor
You're welcome! Glad it resolved your issue.
Don't worry, this is the most common and obvious mistake. 🙂