Using VBA to execute Scenarios Based On Combo Box Selection on an Inactive Worksheet

Zwen

New Member
Joined
Jul 22, 2011
Messages
8
Hi, I am new to VBA so please excuse this question if it appears to be elementary. I am working on a model and am trying to write a code in VBA that allows me to operate scenarios embedded in Scenario Manager on an active worksheet from an inactive worksheet.

I have managed to write a code that runs the scenarios from a combo box actually on the active worksheet using 'Worksheet' 'Change' in VBA:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$O$16" Then
ActiveSheet.Scenarios(Target.Value).Show
End If

But am struggling to write a code that will allow me to operate the same scenarios from an alternative worksheet within the same work book. The ActiveWorksheet is called 'NGN Inputs' FYI and is "Sheet 14" and the Inactive worksheet (i.e. the one not containing the scenarios) is called 'Assumptions' ("Sheet4")

Again this is probably fairly elementary but I am new to VBA and would appreciate any help.

Many thanks.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I think if you reference the sheet you want to change (rather than ActiveSheet) it should work (hopefully):

Rich (BB code):
If Target.Address = "$O$16" Then Sheets("NGN Inputs").Scenarios(Target.Text).Show
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,282
Members
452,902
Latest member
Knuddeluff

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