The line which sets MyRange gives the error with the detail of "Object variable or With block variable not set." I'm hoping that there is simply a typo or something easy I'm missing.
And any tips on a better way to do this sort (or if it will even work once I get past the error LOL) would be appreciated. The 3rd column (the one being sorted on) is a datetime format. The SourceFile1 is exported from another program.
And any tips on a better way to do this sort (or if it will even work once I get past the error LOL) would be appreciated. The 3rd column (the one being sorted on) is a datetime format. The SourceFile1 is exported from another program.
Code:
Option Explicit
Const SourceSheet As String = "Page 1"
Const S1SC As Integer = 3
Const Source1FirstLine As Integer = 2
Const Source1LastColumn As Integer = 13
Sub CallsReport()
Dim SourceBook1 As String
Dim MyRange As Range
Dim SortRange As Range
SourceBook1 = “FileName.xlsx”
Source1LastLine = Workbooks(SourceBook1).Sheets(SourceSheet).Range("A1").End(xlDown).Row
'Sort Source1
MyRange = Range(Workbooks(SourceBook1).Sheets(SourceSheet).Cells(Source1FirstLine, 1), _
Workbooks(SourceBook1).Sheets(SourceSheet).Cells(Source1LastLine, Source1LastColumn))
SortRange = Range(Workbooks(SourceBook1).Sheets(SourceSheet).Cells(Source1FirstLine, S1SC), _
Workbooks(SourceBook1).Sheets(SourceSheet).Cells(Source1FirstLine, S1SC))
MyRange.Sort key1:=Range(SortRange), order1:=xlDescending
End Sub 'Calls Report