Newbie VBA Question

BRWFS15

New Member
Joined
Dec 5, 2019
Messages
3
Office Version
  1. 2013
Platform
  1. Windows
Hi All,

I'm fairly new at VBA and this one has stumped me. I have a worksheet with two separate dropdown lists. I'm trying to point each dropdown to their own separate pivot table by using Worksheet_Change. The chosen value will filter the pivot table with the same value.

Excel is giving me an ambiguous error as I can't use two Worksheet_Changes. I need some help combining, here is what I have:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
Call Piv
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("K6")) Is Nothing Then Exit Sub
Call Opportunity
End Sub

Thanks in advance!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Try:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A1,K6")) Is Nothing Then Exit Sub
    Select Case Target.Address
        Case "$A$1"
            Call Piv
        Case "$K$6"
            Call Opportunity
    End Select
End Sub
 
Upvote 0
Thanks mumps - works like a charm, and I learned something new. Appreciate your help!
 
Upvote 0
You are very welcome. :)
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,747
Members
448,989
Latest member
mariah3

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