Hi,
The code is running as it should when I'm on Sheet8.
But I want to activate the code (to run on Sheet8 only) when I click on a shortcut button I added on another sheet.
But I always get an error: "Run-time error '1004': The Sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort box isn't the same or blank."
The code is running as it should when I'm on Sheet8.
But I want to activate the code (to run on Sheet8 only) when I click on a shortcut button I added on another sheet.
But I always get an error: "Run-time error '1004': The Sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort box isn't the same or blank."
VBA Code:
Dim ws As Worksheet
Dim Rng As Range
Set ws = Worksheets("Sheet8")
Set Rng = ws.Range("A1:M500")
'sort data from smallest to largest number in column K
Rng.Sort Key1:=Range("K:K"), Order1:=xlDescending