pivottable vs VBTrigger

D

Dale

Small bit of help needed for 2 items.
I have a pivot table, which I want to have a user type in a value in cell
B3. 1) If the value is found in the drop down list, change the pivot table,
2) if not, display a message box saying so.
1) This works, sort of, but the code just keeps on running.
2) I haven’t got here yet but any suggestions would be welcome.

Tks

Private Sub Worksheet_Calculate()
Worksheet_Change Range("VB_Trigger") 'Named range on Sheet Pivot-Table",
location B3
End Sub
''***********************************************************************************

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim pt As PivotTable
Dim pfStockNumber As PivotField 'The PAGE FIELD
Dim strSN As String 'Named range on Sheet Pivot-Table",
location B3
Set pt = ActiveSheet.PivotTables(1)
Set pfStockNumber = pt.PivotFields("STOCK#")
Application.ScreenUpdating = False
strSN = ActiveSheet.Range("B3").Value

' Set up the event to watch B3 single cell.
If Target.Address = Range("VB_Trigger").Address Then

ActiveSheet.PivotTables("PivotTable1").PivotFields("Stock#").CurrentPage =
strSN
Else
MsgBox "Stock Number Not Found" 'I haven't worked on this part yet.
End If

Range("A1").Select
Application.ScreenUpdating = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top