I keep getting the error 91 but i cant figure out what is wrong here.

rmason

New Member
Joined
Nov 27, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Sub Refsh_Pvt()
'
' Refsh_Pvt Macro
'

'Grab Pivot Table Info

Sheets("Reject Data").Select
Range("U9:W133").Select
Selection.Copy

'Paste into N8

Range("N8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

'Filter Data

Range("N8:P65").Select
Application.CutCopyMode = False
Selection.AutoFilter
ActiveWorkbook.Worksheets("Reject Data").AutoFilter.Sort.SortFields.Add2 Key _
:=Range("N8:P165"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal

With ActiveWorkbook.Worksheets("Reject Data").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

'Select N4
Range("N4").Select
End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Sub Refsh_Pvt()
'
' Refsh_Pvt Macro
'

'Grab Pivot Table Info

Sheets("Reject Data").Select
Range("U9:W59").Select
Selection.Copy

'Paste into N9

Range("N9").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

'Filter Data

Range("N9:P59").Select
Application.CutCopyMode = False
Selection.AutoFilter
ActiveWorkbook.Worksheets("Reject Data").AutoFilter.Sort.SortFields.Add2 Key _
:=Range("N9:P59"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal

With ActiveWorkbook.Worksheets("Reject Data").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

'Select N4
Range("N4").Select
End Sub



I fixed the cells, but error is still there
 
Upvote 0
Which column do you want to use as the sort criteria? Does the data you want to sort contain headers? It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0

Forum statistics

Threads
1,225,367
Messages
6,184,542
Members
453,241
Latest member
rahuldev31

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top