Hi All,
I am getting he Subscript out of range error when trying to run this macro. I have the macro on a macro workbook and I am referencing another spreadsheet. any help would be appreciated.
Sub Dater()
Static Count As Integer
Dim Wb As Workbook
Dim Ws As Worksheet
Dim FileStr As String
Set Wb = Workbooks("Pending Approval by Responsible User")
Set Ws = Worksheets("Pending Approval by Responsible") <----- getting error here.. Only get error hen am using for control to call Macro
With Ws.Range("A3").CurrentRegion
Range("A3").Select
Selection.AutoFilter
.AutoFilter Field:=7, Criteria1:=">=" & CLng(Date), Operator:=xlAnd, Criteria2:="<=" & CLng(Date + 10)
End With
ActiveWorkbook.Worksheets("Pending Approval by Responsible").AutoFilter.Sort. _
SortFields.Add Key:=Range("G3:G1000"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Pending Approval by Responsible").AutoFilter. _
Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
I am getting he Subscript out of range error when trying to run this macro. I have the macro on a macro workbook and I am referencing another spreadsheet. any help would be appreciated.
Sub Dater()
Static Count As Integer
Dim Wb As Workbook
Dim Ws As Worksheet
Dim FileStr As String
Set Wb = Workbooks("Pending Approval by Responsible User")
Set Ws = Worksheets("Pending Approval by Responsible") <----- getting error here.. Only get error hen am using for control to call Macro
With Ws.Range("A3").CurrentRegion
Range("A3").Select
Selection.AutoFilter
.AutoFilter Field:=7, Criteria1:=">=" & CLng(Date), Operator:=xlAnd, Criteria2:="<=" & CLng(Date + 10)
End With
ActiveWorkbook.Worksheets("Pending Approval by Responsible").AutoFilter.Sort. _
SortFields.Add Key:=Range("G3:G1000"), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Pending Approval by Responsible").AutoFilter. _
Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With