I suspect you need to fully qualify the Key1
range, because you are calling the code from a different sheet:
Worksheets("EmployeeData").Range("K3:K" & EmpBRange).Sort Key1:=Worksheets("EmployeeData").Range("K3:K" & EmpBRange)
This is generally a good idea.
More Related Contents:
- SumIf using Excel VBA
- How can I call a macro which contains a loop but only run one iteration of that loop?
- Test or check if sheet exists
- Copy from one workbook and paste into another
- How to copy Outlook mail message into excel using VBA or Macros
- For Loop not fully cycling in excel VBA [duplicate]
- Unique Random Numbers using VBA
- Populate unique values into a VBA array from Excel
- Excel VBA App stops spontaneously with message “Code execution has been halted”
- How to remove all non alphanumeric characters from a string except period and space in excel?
- Closing Excel Application using VBA
- How to clear memory to prevent “out of memory error” in excel vba?
- Assign on-click VBA function to a dynamically created button on Excel Userform
- Delete Row based on Search Key VBA
- How to add a button programmatically in VBA next to some sheet cell data?
- What are the benefits of setting objects to “Nothing”
- Using a wildcard to open an excel workbook
- How can I kill task manager processes through VBA code?
- VBA: Usage of parentheses for a method
- Fully reference a worksheet by codename
- OnTime for less than 1 second without becoming Unresponsive
- Get Unicode characters with charcode values greater hex `FFFF`
- How do I click a link on a web page using Excel VBA?
- Ping IP Address with VBA code and return results in Excel
- VBA copy cells value and format
- Select entire column in table using Excel VBA
- Create hyperlink to another sheet
- Reducing WithEvent declarations and subs with VBA and ActiveX
- Convert Early Binding VBA to Late Binding VBA : Excel to Outlook Contacts
- How to get the range of the visible rows after applying an advanced filter in Excel (VBA)