我正在尝试在Excel中运行多个价格场景,并让VBA将每个场景的摘要输出复制并粘贴到特定区域。问题是我只在一个场景的输出中复制并粘贴了多个列,而不是相应列中的多个场景。
我的代码是:
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