Originally Posted by
Rajesh Kr Joshi
Hi,
I am trying to auto short(descending) values if a value changes in range D4 to D9. Attaches is the excel file and below is the code I am trying (seems I am doing something wrong).
Please help.
Auto Shorting.xlsm
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D4:D8")) Is Nothing Then
Call DataS
End If
End Sub
Sub DataS()
Range("B3:E8").Sort _
Key1:=Range("E3"), Order1:=xlDescending, Header:=xlYes
End Sub
Thanks
Rajesh
Put this in modul
Code:
Sub DataS()
Range("B3:E8").Sort _
Key1:=Range("E3"), Order1:=xlDescending, Header:=xlYes
End Sub
Then you have to refresh pivot table after you insert or change data in sheet Data. Try something like this in sheet module:
Code:
ActiveSheet.PivotTables("PivotTable1").RefreshTable
Hope it helps.
Bookmarks