1

I am trying to run multiple price scenarios in excel and have VBA copy and paste the summary outputs of each scenario into a particular area. The problem is that I am getting only one scenario's output copied and pasted in multiple columns versus multiple scenarios in their appropriate columns.

The code I have is:

Sub UpsideDownside()

Application.ScreenUpdating = False

'Set Names of Area Tabs and Blowdown Tabs'
    Sheets("Sensitivities").Select
    Dim area1, area2, area3 As String
    Dim blow1, blow2 As String
    area1 = Range("K26")
    area2 = Range("K27")
    area3 = Range("K28")
    area4 = Range("K29")
    blow1 = Range("O26")
    blow2 = Range("O27")
    blow3 = Range("O28")
    blow4 = Range("O29")


'Set Commodity Prices to Base Case and run base case'
    Sheets("Commodity_Prices").Range("J5") = "Base"
    Sheets("Commodity_Prices").Range("J57") = "Base"
    Sheets(Array(area1, area2, area3, area4)).Select
    Sheets(area1).Activate
    Range("X7:X24").Select
    Selection.Copy
    Range("AA7").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Sheets(Array(blow1, blow2)).Select
    Sheets(blow1).Activate
    Range("V7:V19").Select
    Selection.Copy
    Range("Y7").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False

'Set Commodity Prices to Upside Case and run upside'
    Sheets("Commodity_Prices").Range("J5") = "Upside"
    Sheets("Commodity_Prices").Range("J57") = "Upside"
    Sheets(Array(area1, area2, area3, area4)).Select
    Sheets(area1).Activate
    Range("X7:X24").Select
    Selection.Copy
    Range("AB7").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Sheets(Array(blow1, blow2)).Select
    Sheets(blow1).Activate
    Range("V7:V19").Select
    Selection.Copy
    Range("Z7").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Sheets("NAV").Select
    Range("D56:E67").Select
    Selection.Copy
    Range("L56").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
       Range("D72:D75").Select
    Selection.Copy
    Range("L72").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False

'Set Commodity Prices to Commercial Bank and run downside'
    Sheets("Commodity_Prices").Range("J5") = "Commercial Bank"
    Sheets("Commodity_Prices").Range("J57") = "Commercial Bank"
    Sheets(Array(area1, area2, area3, area4)).Select
    Sheets(area1).Activate
    Range("C19").Select
    ActiveCell.FormulaR1C1 = "2"
    Range("X7:X24").Select
    Selection.Copy
    Range("Z7").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Sheets(Array(blow1, blow2)).Select
    Sheets(blow1).Activate
    Range("V7:V19").Select
    Selection.Copy
    Range("X7").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Sheets("NAV").Select
    Range("D56:E67").Select
    Selection.Copy
    Range("H56").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Range("D72:D75").Select
    Selection.Copy
    Range("H72").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False


'Set Commodity Prices to NYMEX and run Strip'
    Sheets("Commodity_Prices").Range("J5") = "NYMEX"
    Sheets("Commodity_Prices").Range("J57") = "NYMEX"
    Sheets(Array(area1, area2, area3, area4)).Select
    Sheets(area1).Activate
    Range("C19").Select
    ActiveCell.FormulaR1C1 = "2"
    Range("X7:X24").Select
    Selection.Copy
    Range("Y7").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
   Sheets(Array(blow1, blow2)).Select
    Sheets(blow1).Activate
    Range("V7:V19").Select
    Selection.Copy
    Range("W7").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Sheets("NAV").Select
    Range("D56:E67").Select
    Selection.Copy
    Range("O56").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Range("D72:D75").Select
    Selection.Copy
    Range("O72").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False

'Reset Commodity Prices to Base Case and Inventory development value from 2P to original'
    Sheets("Commodity_Prices").Range("J5") = "Base"
    Sheets("Commodity_Prices").Range("J57") = "Base"
    Sheets(Array(area1, area2, area3, area4)).Select
    Sheets(area1).Activate
    Range("AA18").Select
    Selection.Copy
    Range("C19").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Sheets("Sensitivities").Select

End Sub
  • 1
    With all the `Activate` and `Select` going on it is difficult to follow what's happening or what is supposed to be happening. Have a look at [this](http://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros) and see if you can't restructure the code a bit, first. – David Zemens Jan 24 '17 at 20:37

0 Answers0