Filter Pivot table using named range

deletedalien

Well-known Member
Joined
Dec 8, 2008
Messages
505
Office Version
  1. 2013
Platform
  1. Windows
Hi guys, so im trying to have several pivots change automatically depending on the user who's logged in, i have a named range called repid where the rep id will sit once the workbook is opened, But for whatever reason i cant get my macro to work,

here is what i have:



Code:
Private Sub Workbook_Open()
Dim UserN As String
UserN = Environ("UserName")
Sheets("Rep Data").Range("E2").Value = UserN
Sheets("ISR Camp Overview All").Select
Range("F1").Value = Range("Repid")
Application.Calculate
Sheets("New Customers").Select
ActiveSheet.PivotTables("New_Customers").PivotFields("ISR").Value = Range("Repid")
Sheets("D03").Select
Application.CalculateFull
End Sub

i also tried:

Code:
Private Sub Workbook_Open()
Dim UserN As String
UserN = Environ("UserName")
Sheets("Rep Data").Range("E2").Value = UserN
Sheets("ISR Camp Overview All").Select
Range("F1").Value = Range("Repid")
Application.Calculate
Sheets("New Customers").Select
ActiveSheet.PivotTables("New_Customers").PivotFields("ISR").CurrentPage = Range("Repid")
Sheets("D03").Select
Application.CalculateFull
End Sub
and neither codes work,

Any ideas??

thanks in advance for your help.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I FIGURED IT OUT!!! :)

Rich (BB code):
Private Sub Workbook_Open()
Dim UserN As String
UserN = Environ("UserName")
Sheets("Rep Data").Range("E2").Value = UserN
Sheets("ISR Camp Overview All").Select
Range("F1").Value = Range("Repid")
rep = Range("repid")
Application.Calculate
Sheets("New Customers").Select
ActiveSheet.PivotTables("New_Customers").PivotFields("ISR").CurrentPage = rep
Sheets("D03 Lost Quote Summary").Select
ActiveSheet.PivotTables("Lost_Quote_Summary").PivotFields("ISR").CurrentPage = rep
Sheets("D03 Reason Haven't Ordered Summ").Select
ActiveSheet.PivotTables("Reason_Havent_Ordered_Summ").PivotFields("ISR").CurrentPage = rep
Sheets("D03").Select
Application.CalculateFull
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,051
Messages
6,053,220
Members
444,648
Latest member
sinkuan85

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