OaklandJim
Well-known Member
- Joined
- Nov 29, 2018
- Messages
- 855
- Office Version
- 365
- Platform
- Windows
I cannot figure out what to look at to fix this issue. Sub used for sorting worked well until it did not. Now I get the error message "You cannot change part of an array" on the .Apply method. Below is the offending sub and debug.print output.
What am I doing wrong? Syntax? It must be something simple because, like I said, it worked before. I don't know of any changes to the dataset that I have made.
rAllData = $D$7:$V$107
Range(Header_Event).Address = $G$7
Range(Header_ShiftStart).Address = $J$7
Range(Header_StartTime).Address = $M$7
Range(Header_LastName).Address = $F$7
What am I doing wrong? Syntax? It must be something simple because, like I said, it worked before. I don't know of any changes to the dataset that I have made.
VBA Code:
Sub Sort_Events_Master()
Dim rAllData As Range
With [Master]
Set rAllData = .Range("Header_LastName").CurrentRegion
Debug.Print "rAllData = " & rAllData.Address
Debug.Print "Range(Header_Event).Address = " & .Range("Header_Event").Address
Debug.Print "Range(Header_ShiftStart).Address = " & .Range("Header_ShiftStart").Address
Debug.Print "Range(Header_StartTime).Address = " & .Range("Header_StartTime").Address
Debug.Print "Range(Header_LastName).Address = " & .Range("Header_LastName").Address
With .Sort
.Header = xlYes
.SortFields.Clear
.SortFields.Add Key:=Range("Header_Event").Offset(1), Order:=xlAscending
.SortFields.Add Key:=Range("Header_ShiftStart").Offset(1), Order:=xlAscending
.SortFields.Add Key:=Range("Header_StartTime").Offset(1), Order:=xlAscending
.SortFields.Add Key:=Range("Header_LastName").Offset(1), Order:=xlAscending
.SetRange rAllData
.Apply
End With '.Sort
Application.CalculateFull
End With
End Sub
rAllData = $D$7:$V$107
Range(Header_Event).Address = $G$7
Range(Header_ShiftStart).Address = $J$7
Range(Header_StartTime).Address = $M$7
Range(Header_LastName).Address = $F$7