View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Daggi Daggi is offline
external usenet poster
 
Posts: 2
Default Worksheet_Change(ByVal Target As Excel.Range)

I'm trying to alter multiple pivot tables and its working great as long as i
enter a number higher or equal to 100 in the target cell. I have to be able
to use numbers between 0 an 100 to. What am i doing wrong?

My code:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Dim pt01 As PivotTable
Dim pf01 As PivotField
Dim pi01 As PivotItem

Dim pt02 As PivotTable
Dim pf02 As PivotField
Dim pi02 As PivotItem

Set pt01 = Sheets("Noter").PivotTables("3601-Fellesutgifter")
Set pt02 = Sheets("Saldobalanse").PivotTables("Saldobalanse")

Set pf01 = pt01.PivotFields("IK")
Set pf02 = pt02.PivotFields("IK")

If Target.Address = "$A$2" Then

For Each pi01 In pf01.PivotItems
If pi01 = Target.Value Then
pf01.CurrentPage = Target.Value
Exit For
End If
Next pi01

For Each pi02 In pf02.PivotItems
If pi02 = Target.Value Then
pf02.CurrentPage = Target.Value
Exit For
End If
Next pi02

End If

End Sub

I realy hope you can help!



--
Daggi