G
Gina Liddle
Is there a more efficient way to write the below code.
I want to match the system username (fOSUserName) to a PivotItem of
PivotField "PL". If there's a match make it visible and hide all other
pivotitems and if there's no match display all items.
Ta.
G
'count number of PLs in list
ResNum = JobPF.PivotItems.Count
'redimension variable
ReDim ResID(ResNum)
UserName = fOSUserName
'loop through and hide all items in PL field except "(blank)"
For Res = 1 To ResNum
ResID(Res) = JobPF.PivotItems(Res)
If ResID(Res) <> "(blank)" Then
'match logged in username with PL list
If UserName <> ResID(Res) Then
JobPF.PivotItems(ResID(Res)).Visible = False
TimePF.PivotItems(ResID(Res)).Visible = False
Else
JobPF.PivotItems(ResID(Res)).Visible = True
TimePF.PivotItems(ResID(Res)).Visible = True
End If
End If
Next Res
PLItems = JobPF.VisibleItems.Count
If PLItems < 2 Then
For Res = 1 To ResNum
JobPF.PivotItems(ResID(Res)).Visible = True
TimePF.PivotItems(ResID(Res)).Visible = True
Next Res
MsgBox "Currently you aren't defined as a PL", vbCritical, "User
Name " _
& UserName
Else
MsgBox "Project Leader " & UserName & " has been selected as a
filter" _
& " in these reports.", vbOKOnly, "Project Leader " & UserName
End If
I want to match the system username (fOSUserName) to a PivotItem of
PivotField "PL". If there's a match make it visible and hide all other
pivotitems and if there's no match display all items.
Ta.
G
'count number of PLs in list
ResNum = JobPF.PivotItems.Count
'redimension variable
ReDim ResID(ResNum)
UserName = fOSUserName
'loop through and hide all items in PL field except "(blank)"
For Res = 1 To ResNum
ResID(Res) = JobPF.PivotItems(Res)
If ResID(Res) <> "(blank)" Then
'match logged in username with PL list
If UserName <> ResID(Res) Then
JobPF.PivotItems(ResID(Res)).Visible = False
TimePF.PivotItems(ResID(Res)).Visible = False
Else
JobPF.PivotItems(ResID(Res)).Visible = True
TimePF.PivotItems(ResID(Res)).Visible = True
End If
End If
Next Res
PLItems = JobPF.VisibleItems.Count
If PLItems < 2 Then
For Res = 1 To ResNum
JobPF.PivotItems(ResID(Res)).Visible = True
TimePF.PivotItems(ResID(Res)).Visible = True
Next Res
MsgBox "Currently you aren't defined as a PL", vbCritical, "User
Name " _
& UserName
Else
MsgBox "Project Leader " & UserName & " has been selected as a
filter" _
& " in these reports.", vbOKOnly, "Project Leader " & UserName
End If