array limits? help with run-time error 7

Speedy

New Member
Joined
Apr 29, 2009
Messages
18
i keep getting this error and i am not sure how to fix it. any thoughts/ideas/suggestions?

i am using excel 2007 and the error occurs in the procedure labeled "pge_e1" when i try to redim the array "PVElectOutput_E1".

this has been a frustrating error so any help will be greatly appreciated!


Code:
    Type CZPVinfo                         ' create data type to store pv and CZ data
        CapCost As Double
        InvertCost As Double
        SysSize As Double
        BaselineZone As String
        BaseAllSum As Double
        BaseAllWint As Double
        BaseRateSche As String
        AltRateSche As String
        PV_Prod_1kW_E1 As Variant
        PV_Prod_1kW_E6 As Variant
        Res_Load_E1 As Variant
        Res_Load_E6 As Variant
    End Type

    Dim CZinfo() As CZPVinfo

    Dim PVElectOutput_E1() As Double

    Dim e1_summer_rateschd(0 To 4, 0 To 2, 0 To 4) As Double     'summer and winter rate schedules for each cz under e1
    Dim e1_winter_rateschd(0 To 4, 0 To 2, 0 To 4) As Double
    Dim PVDegradFactor As Double
    Dim PVLife As Double
    Dim Nyears As Integer
    Dim enegcutoff_e1 As Variant    'store annual energy cuttoffs by tier: tier level;baseline zone;e1 & e6
    Dim enegcutoff_e6 As Variant
    Dim resengloads As Variant         'store annual residential energy based on load curve

Sub PV_Retrofit()
    
    'the purpose of this procedure is to mainly read data for use by other procedures
    
    Dim BYear As Integer
    Dim EYear As Integer
    
    Dim i As Integer, j As Integer, k As Integer, ii As Integer, jj As Integer, dd As Integer
    
    Dim output As Range
    Dim output2 As Range
    
    BYear = Worksheets("DataInput").Range("C12")
    EYear = Worksheets("DataInput").Range("C13")
    PVDegradFactor = Worksheets("DataInput").Range("C22")
    PVLife = Worksheets("DataInput").Range("C21")
    
    Nyears = EYear - BYear + 1
    
    ReDim CZinfo(0 To 4, 0 To 4, 0 To (Nyears - 1)) 'cz, tier level, year of analysis
    
    enegcutoff_e1 = Worksheets("DataInput").Range("H93:Q97")
    enegcutoff_e6 = Worksheets("DataInput").Range("H112:Q116")
    resengloads = Worksheets("DataInput").Range("A60:D69")
    
'    For i = 0 To (Nyears - 1)       'print out time frame of analysis for each climate zone & tier
'        'baseline
'        Worksheets("PGEretrofit").Range("E4").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("E21").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("E37").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("E53").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("E69").Offset(0, i) = BYear + i
'        't2
'        Worksheets("PGEretrofit").Range("T4").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("T21").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("T37").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("T53").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("T69").Offset(0, i) = BYear + i
'        't3
'        Worksheets("PGEretrofit").Range("AI4").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("AI21").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("AI37").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("AI53").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("AI69").Offset(0, i) = BYear + i
'        't4
'        Worksheets("PGEretrofit").Range("AX4").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("AX21").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("AX37").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("AX53").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("AX69").Offset(0, i) = BYear + i
'        't5
'        Worksheets("PGEretrofit").Range("BM4").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("BM21").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("BM37").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("BM53").Offset(0, i) = BYear + i
'        Worksheets("PGEretrofit").Range("BM69").Offset(0, i) = BYear + i
'    Next i
    
    
    For i = 0 To 4  'cz
        For j = 0 To 4  'tier: 0=baseline; 1=130% baseline;2=200% baseline; 3=300% baseline; 4 = > 300% baseline
            For k = 0 To (Nyears - 1) 'analysis year
                'pv price
                Select Case Worksheets("DataInput").Range("I28")
                    Case 1
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("G10").Offset(ii, 0)
                        Next ii
                    Case 2
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("H10").Offset(ii, 0)
                        Next ii
                    Case 3
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("I10").Offset(ii, 0)
                        Next ii
                    Case 4
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("J10").Offset(ii, 0)
                        Next ii
                    Case 5
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("K10").Offset(ii, 0)
                        Next ii
                    Case 6
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("L10").Offset(ii, 0)
                        Next ii
                    Case 7
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("M10").Offset(ii, 0)
                        Next ii
                    Case 8
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("N10").Offset(ii, 0)
                        Next ii
                    Case 9
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("O10").Offset(ii, 0)
                        Next ii
                    Case 10
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("P10").Offset(ii, 0)
                        Next ii
                    Case 11
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("Q10").Offset(ii, 0)
                        Next ii
                    Case 12
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("R10").Offset(ii, 0)
                        Next ii
                    Case 13
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).CapCost = Worksheets("DataInput").Range("S10").Offset(ii, 0)
                        Next ii
                End Select
                'inverter price
                Select Case Worksheets("DataInput").Range("I55")
                    Case 1
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).InvertCost = Worksheets("DataInput").Range("G37").Offset(ii, 0)
                        Next ii
                    Case 2
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).InvertCost = Worksheets("DataInput").Range("H37").Offset(ii, 0)
                        Next ii
                    Case 3
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).InvertCost = Worksheets("DataInput").Range("I37").Offset(ii, 0)
                        Next ii
                    Case 4
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).InvertCost = Worksheets("DataInput").Range("J37").Offset(ii, 0)
                        Next ii
                    Case 5
                        For ii = 0 To (Nyears - 1)
                            CZinfo(i, j, ii).InvertCost = Worksheets("DataInput").Range("K37").Offset(ii, 0)
                        Next ii
                End Select
                'system size
                CZinfo(i, j, k).SysSize = Worksheets("DataInput").Range("G65").Offset(k, j)
                'baseline zone
                CZinfo(i, j, k).BaselineZone = Worksheets("DataInput").Range("C50").Offset(i, 0)
                'base and alternative rate comparison
                CZinfo(i, j, k).BaseRateSche = Worksheets("DataInput").Range("G137").Offset(k, 0)
                CZinfo(i, j, k).AltRateSche = Worksheets("DataInput").Range("H137").Offset(k, 0)
                'PV production schedule
                Select Case CZinfo(i, j, k).BaselineZone
                    Case "P"
                       CZinfo(i, j, k).PV_Prod_1kW_E1 = Worksheets("PVLoadData - PGE").Range("B824").CurrentRegion
                       CZinfo(i, j, k).PV_Prod_1kW_E6 = Worksheets("PVLoadData - PGE").Range("B8").CurrentRegion
                    Case "Q"
                        CZinfo(i, j, k).PV_Prod_1kW_E1 = Worksheets("PVLoadData - PGE").Range("AK824").CurrentRegion
                        CZinfo(i, j, k).PV_Prod_1kW_E6 = Worksheets("PVLoadData - PGE").Range("AK8").CurrentRegion
                    Case "R"
                        CZinfo(i, j, k).PV_Prod_1kW_E1 = Worksheets("PVLoadData - PGE").Range("BT824").CurrentRegion
                        CZinfo(i, j, k).PV_Prod_1kW_E6 = Worksheets("PVLoadData - PGE").Range("BT8").CurrentRegion
                    Case "S"
                        CZinfo(i, j, k).PV_Prod_1kW_E1 = Worksheets("PVLoadData - PGE").Range("DC824").CurrentRegion
                        CZinfo(i, j, k).PV_Prod_1kW_E6 = Worksheets("PVLoadData - PGE").Range("DC8").CurrentRegion
                    Case "T"
                        CZinfo(i, j, k).PV_Prod_1kW_E1 = Worksheets("PVLoadData - PGE").Range("EL824").CurrentRegion
                        CZinfo(i, j, k).PV_Prod_1kW_E6 = Worksheets("PVLoadData - PGE").Range("EL8").CurrentRegion
                    Case "V"
                        CZinfo(i, j, k).PV_Prod_1kW_E1 = Worksheets("PVLoadData - PGE").Range("FU824").CurrentRegion
                        CZinfo(i, j, k).PV_Prod_1kW_E6 = Worksheets("PVLoadData - PGE").Range("FU8").CurrentRegion
                    Case "W"
                        CZinfo(i, j, k).PV_Prod_1kW_E1 = Worksheets("PVLoadData - PGE").Range("HD824").CurrentRegion
                        CZinfo(i, j, k).PV_Prod_1kW_E6 = Worksheets("PVLoadData - PGE").Range("HD8").CurrentRegion
                    Case "X"
                        CZinfo(i, j, k).PV_Prod_1kW_E1 = Worksheets("PVLoadData - PGE").Range("IM824").CurrentRegion
                        CZinfo(i, j, k).PV_Prod_1kW_E6 = Worksheets("PVLoadData - PGE").Range("IM8").CurrentRegion
                    Case "Y"
                        CZinfo(i, j, k).PV_Prod_1kW_E1 = Worksheets("PVLoadData - PGE").Range("JV824").CurrentRegion
                        CZinfo(i, j, k).PV_Prod_1kW_E6 = Worksheets("PVLoadData - PGE").Range("JV8").CurrentRegion
                    Case "Z"
                        CZinfo(i, j, k).PV_Prod_1kW_E1 = Worksheets("PVLoadData - PGE").Range("LE824").CurrentRegion
                        CZinfo(i, j, k).PV_Prod_1kW_E6 = Worksheets("PVLoadData - PGE").Range("LE8").CurrentRegion
                End Select
                'store baseline allocation - daily kWh for summer and winter
                Select Case CZinfo(i, j, k).BaselineZone
                    Case "P"
                        CZinfo(i, j, k).BaseAllSum = Worksheets("DataInput").Range("H90")
                        CZinfo(i, j, k).BaseAllWint = Worksheets("DataInput").Range("H91")
                    Case "Q"
                        CZinfo(i, j, k).BaseAllSum = Worksheets("DataInput").Range("I90")
                        CZinfo(i, j, k).BaseAllWint = Worksheets("DataInput").Range("I91")
                    Case "R"
                        CZinfo(i, j, k).BaseAllSum = Worksheets("DataInput").Range("J90")
                        CZinfo(i, j, k).BaseAllWint = Worksheets("DataInput").Range("J91")
                    Case "S"
                        CZinfo(i, j, k).BaseAllSum = Worksheets("DataInput").Range("K90")
                        CZinfo(i, j, k).BaseAllWint = Worksheets("DataInput").Range("K91")
                    Case "T"
                        CZinfo(i, j, k).BaseAllSum = Worksheets("DataInput").Range("L90")
                        CZinfo(i, j, k).BaseAllWint = Worksheets("DataInput").Range("L91")
                    Case "V"
                        CZinfo(i, j, k).BaseAllSum = Worksheets("DataInput").Range("M90")
                        CZinfo(i, j, k).BaseAllWint = Worksheets("DataInput").Range("M91")
                    Case "W"
                        CZinfo(i, j, k).BaseAllSum = Worksheets("DataInput").Range("N90")
                        CZinfo(i, j, k).BaseAllWint = Worksheets("DataInput").Range("N91")
                    Case "X"
                        CZinfo(i, j, k).BaseAllSum = Worksheets("DataInput").Range("O90")
                        CZinfo(i, j, k).BaseAllWint = Worksheets("DataInput").Range("O91")
                    Case "Y"
                        CZinfo(i, j, k).BaseAllSum = Worksheets("DataInput").Range("P90")
                        CZinfo(i, j, k).BaseAllWint = Worksheets("DataInput").Range("P91")
                    Case "Z"
                        CZinfo(i, j, k).BaseAllSum = Worksheets("DataInput").Range("Q90")
                        CZinfo(i, j, k).BaseAllWint = Worksheets("DataInput").Range("Q91")
                End Select
            Next k
        Next j
    Next i
           
    'the code below stores the unadjusted residential load by cz, tier, and year of analysis
    For i = 0 To 4  'cz
        For j = 0 To 4  'tier: 0=baseline; 1=130% baseline;2=200% baseline; 3=300% baseline; 4 = > 300% baseline
            For k = 0 To (Nyears - 1) 'analysis year
                Select Case CZinfo(i, j, k).BaselineZone
                    Case "P"
                        CZinfo(i, j, k).Res_Load_E1 = Worksheets("ResLoad - PGE").Range("B822").CurrentRegion
                        CZinfo(i, j, k).Res_Load_E6 = Worksheets("ResLoad - PGE").Range("B8").CurrentRegion
                    Case "Q"
                        CZinfo(i, j, k).Res_Load_E1 = Worksheets("ResLoad - PGE").Range("AK822").CurrentRegion
                        CZinfo(i, j, k).Res_Load_E6 = Worksheets("ResLoad - PGE").Range("AK8").CurrentRegion
                    Case "R"
                        CZinfo(i, j, k).Res_Load_E1 = Worksheets("ResLoad - PGE").Range("BT822").CurrentRegion
                        CZinfo(i, j, k).Res_Load_E6 = Worksheets("ResLoad - PGE").Range("BT8").CurrentRegion
                    Case "S"
                        CZinfo(i, j, k).Res_Load_E1 = Worksheets("ResLoad - PGE").Range("DC822").CurrentRegion
                        CZinfo(i, j, k).Res_Load_E6 = Worksheets("ResLoad - PGE").Range("DC8").CurrentRegion
                    Case "T"
                        CZinfo(i, j, k).Res_Load_E1 = Worksheets("ResLoad - PGE").Range("EL822").CurrentRegion
                        CZinfo(i, j, k).Res_Load_E6 = Worksheets("ResLoad - PGE").Range("EL8").CurrentRegion
                    Case "V"
                        CZinfo(i, j, k).Res_Load_E1 = Worksheets("ResLoad - PGE").Range("FU822").CurrentRegion
                        CZinfo(i, j, k).Res_Load_E6 = Worksheets("ResLoad - PGE").Range("FU8").CurrentRegion
                    Case "W"
                        CZinfo(i, j, k).Res_Load_E1 = Worksheets("ResLoad - PGE").Range("HD822").CurrentRegion
                        CZinfo(i, j, k).Res_Load_E6 = Worksheets("ResLoad - PGE").Range("HD8").CurrentRegion
                    Case "X"
                        CZinfo(i, j, k).Res_Load_E1 = Worksheets("ResLoad - PGE").Range("IM822").CurrentRegion
                        CZinfo(i, j, k).Res_Load_E6 = Worksheets("ResLoad - PGE").Range("IM8").CurrentRegion
                    Case "Y"
                        CZinfo(i, j, k).Res_Load_E1 = Worksheets("ResLoad - PGE").Range("JV822").CurrentRegion
                        CZinfo(i, j, k).Res_Load_E6 = Worksheets("ResLoad - PGE").Range("JV8").CurrentRegion
                    Case "Z"
                        CZinfo(i, j, k).Res_Load_E1 = Worksheets("ResLoad - PGE").Range("LE822").CurrentRegion
                        CZinfo(i, j, k).Res_Load_E6 = Worksheets("ResLoad - PGE").Range("LE8").CurrentRegion
                End Select
            Next k
        Next j
    Next i
    
    For i = 0 To 4  'cz     this section will adjust residential hourly load based on tier cutoffs
        For j = 0 To 4  'tier: 0=baseline; 1=130% baseline;2=200% baseline; 3=300% baseline; 4 = > 300% baseline
            For k = 0 To (Nyears - 1) 'analysis year
                Select Case CZinfo(i, j, k).BaselineZone
                    Case "P"
                        dd = 1
                        Select Case j
                            Case 0
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 1
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 2
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 3
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 4
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                        End Select
                    Case "Q"
                        dd = 2
                        Select Case j
                            Case 0
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 1
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 2
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 3
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 4
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                        End Select
                    Case "R"
                        dd = 3
                        Select Case j
                            Case 0
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 1
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 2
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 3
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 4
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                        End Select
                    Case "S"
                        dd = 4
                        Select Case j
                            Case 0
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 1
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 2
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 3
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 4
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                        End Select
                    Case "T"
                        dd = 5
                        Select Case j
                            Case 0
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 1
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 2
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 3
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 4
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                        End Select
                    Case "V"
                        dd = 6
                        Select Case j
                            Case 0
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 1
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 2
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 3
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 4
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                        End Select
                    Case "W"
                        dd = 7
                        Select Case j
                            Case 0
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 1
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 2
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 3
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 4
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                        End Select
                    Case "X"
                        dd = 8
                        Select Case j
                            Case 0
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 1
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 2
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 3
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 4
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                        End Select
                    Case "Y"
                        dd = 9
                        Select Case j
                            Case 0
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 1
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 2
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 3
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 4
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                        End Select
                    Case "Z"
                        dd = 10
                        Select Case j
                            Case 0
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 1
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 2
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 3
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                            Case 4
                                'modify residential load under e1
                                If (enegcutoff_e1(j + 1, dd) <> resengloads(dd, 3)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E1, 1)
                                        For jj = 6 To UBound(CZinfo(i, j, k).Res_Load_E1, 2)
                                            CZinfo(i, j, k).Res_Load_E1(ii, jj) = CZinfo(i, j, k).Res_Load_E1(ii, jj) * (enegcutoff_e1(j + 1, dd) / resengloads(dd, 3))
                                        Next jj
                                    Next ii
                                End If
                                 'modify residential load under e6
                                If (enegcutoff_e6(j + 1, dd) <> resengloads(dd, 4)) Then
                                    For ii = 2 To UBound(CZinfo(i, j, k).Res_Load_E6, 1)
                                        For jj = 10 To UBound(CZinfo(i, j, k).Res_Load_E6, 2)
                                            CZinfo(i, j, k).Res_Load_E6(ii, jj) = CZinfo(i, j, k).Res_Load_E6(ii, jj) * (enegcutoff_e6(j + 1, dd) / resengloads(dd, 4))
                                        Next jj
                                    Next ii
                                End If
                        End Select
                End Select
            Next k
        Next j
    Next i

            
    
    Call pge_e1     'store electricity rates by cz
'    Call pge_e6
    
    
'    Worksheets("Sheet2").Activate
'    For i = 0 To (Nyears - 1)
'        Range("C4").Offset(0, i) = CZinfo(0, 0, i).CapCost
'        Range("C5").Offset(0, i) = CZinfo(0, 0, i).InvertCost
'        Range("C6").Offset(0, i) = CZinfo(0, 0, i).BaselineZone
'        Range("C7").Offset(0, i) = CZinfo(0, 0, i).SysSize
'        Range("C8").Offset(0, i) = CZinfo(0, 0, i).BaseAllSum
'        Range("C9").Offset(0, i) = CZinfo(0, 0, i).BaseAllWint
'        Range("C10").Offset(0, i) = CZinfo(0, 0, i).BaseRateSche
'        Range("C11").Offset(0, i) = CZinfo(0, 0, i).AltRateSche
'    Next i
    
'    check if array is being read correctly
'    i = UBound(CZinfo(0, 0, 0).PV_Prod_1kW_E6, 1)
'    j = UBound(CZinfo(0, 0, 0).PV_Prod_1kW_E6, 2)
'
'    MsgBox i & " " & j
''
'    Worksheets("Sheet2").Activate
'    Set output = Worksheets("Sheet2").Range(Cells(1, 1), Cells(i, j))
'    MsgBox CZinfo(0, 0, 0).BaselineZone
'    output.Value = CZinfo(0, 0, 0).PV_Prod_1kW_E6
    
'    i = UBound(enegcutoff_e1, 1)
'    j = UBound(enegcutoff_e1, 2)
'    MsgBox enegcutoff_e1(5, 10)
'    Worksheets("Sheet2").Activate
'    Set output = Worksheets("Sheet2").Range(Cells(1, 1), Cells(i, j))
'    output.Value = enegcutoff_e1
    
'    i = UBound(CZinfo(0, 0, 0).Res_Load_E6, 1)
'    j = UBound(CZinfo(0, 0, 0).Res_Load_E6, 2)
'    Worksheets("Sheet2").Activate
'    Set output = Worksheets("Sheet2").Range(Cells(1, 1), Cells(i, j))
'    output.Value = CZinfo(0, 4, 0).Res_Load_E6
    
End Sub

Sub pge_e1()

    Dim i As Long, j As Long, k As Long, z As Long, d As Long, h As Long
    ReDim PVElectOutput_E1(0 To 364, 0 To 23, 0 To (PVLife - 1), 0 To (Nyears - 1), 0 To 4, 0 To 4)

    
    For i = 0 To 4  'cz this section builds the electric rate schedule for e1 customers by cz
        For j = 0 To 4  'tier levles
            e1_summer_rateschd(j, 0, i) = Worksheets("DataInput").Range("F93").Offset(j, 0)
            e1_winter_rateschd(j, 0, i) = Worksheets("DataInput").Range("F93").Offset(j, 0)
            Select Case j
                Case 0              'baseline
                    e1_summer_rateschd(j, 1, i) = CZinfo(i, 0, 0).BaseAllSum        'as long as daily kwh allocation doesnt change - this is fine
                    e1_winter_rateschd(j, 1, i) = CZinfo(i, 0, 0).BaseAllWint
                    e1_summer_rateschd(j, 2, i) = e1_summer_rateschd(j, 1, i)
                    e1_winter_rateschd(j, 2, i) = e1_winter_rateschd(j, 1, i)
                Case 1              '130% of baseline
                    e1_summer_rateschd(j, 1, i) = 0.3 * CZinfo(i, 0, 0).BaseAllSum
                    e1_winter_rateschd(j, 1, i) = 0.3 * CZinfo(i, 0, 0).BaseAllWint
                    e1_summer_rateschd(j, 2, i) = 1.3 * CZinfo(i, 0, 0).BaseAllSum
                    e1_winter_rateschd(j, 2, i) = 1.3 * CZinfo(i, 0, 0).BaseAllWint
                Case 2              '200% of baseline
                    e1_summer_rateschd(j, 1, i) = 0.7 * CZinfo(i, 0, 0).BaseAllSum
                    e1_winter_rateschd(j, 1, i) = 0.7 * CZinfo(i, 0, 0).BaseAllWint
                    e1_summer_rateschd(j, 2, i) = 2 * CZinfo(i, 0, 0).BaseAllSum
                    e1_winter_rateschd(j, 2, i) = 2 * CZinfo(i, 0, 0).BaseAllWint
                Case 3              '300% of baseline
                    e1_summer_rateschd(j, 1, i) = 1 * CZinfo(i, 0, 0).BaseAllSum
                    e1_winter_rateschd(j, 1, i) = 1 * CZinfo(i, 0, 0).BaseAllWint
                    e1_summer_rateschd(j, 2, i) = 3 * CZinfo(i, 0, 0).BaseAllSum
                    e1_winter_rateschd(j, 2, i) = 3 * CZinfo(i, 0, 0).BaseAllWint
                Case 4              'over 300% of baseline
                    e1_summer_rateschd(j, 1, i) = 0
                    e1_winter_rateschd(j, 1, i) = 0
                    e1_summer_rateschd(j, 2, i) = 3 * CZinfo(i, 0, 0).BaseAllSum
                    e1_winter_rateschd(j, 2, i) = 3 * CZinfo(i, 0, 0).BaseAllWint
            End Select
        Next j
    Next i
    
    'the section below calculates pv production based on pv profile,system size, and output degradation factor

    For i = 0 To 4                              'cz
        For j = 0 To 4                          'tier
            For k = 0 To (Nyears - 1)           'analysis year
                For z = 0 To (PVLife - 1)       'pv system life year
                    For d = 0 To 364            'day
                        For h = 0 To 23         'hour
                            If z >= 3 Then
                                PVElectOutput_E1(d, h, z, k, j, i) = CZinfo(i, j, k).PV_Prod_1kW_E1(2 + d, 6 + h) * CZinfo(i, j, k).SysSize * (1 - PVDegradFactor) ^ (z - 2)
                            Else
                                PVElectOutput_E1(d, h, z, k, j, i) = CZinfo(i, j, k).PV_Prod_1kW_E1(2 + d, 6 + h) * CZinfo(i, j, k).SysSize

                            End If
                        Next h
                    Next d
                Next z
            Next k
        Next j
    Next i

    
    'the loop below calculates electricity production by pv system depending on location
    'and adjusts for output degradation starting in year 3
'    For i = 1 To 5                      'cz
'        For j = 1 To Nyears       'number of years
'            For z = 1 To PVLife   'pv life
'                For d = 1 To 365        'days of year
'                    For k = 1 To 24     'hours in day
'                        Select Case CZinfo(i - 1, j - 1).BaselineZone
'                            Case "P"
'                                If z >= 3 Then
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_P_E1(d + 1, 5 + k) * (1 - PVDegradFactor) ^ (z - 1)
'                                Else
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_P_E1(d + 1, 5 + k)
'                                End If
'                            Case "Q"
'                                If z >= 3 Then
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_Q_E1(d + 1, 5 + k) * (1 - PVDegradFactor) ^ (z - 1)
'                                Else
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_Q_E1(d + 1, 5 + k)
'                                End If
'                            Case "R"
'                                If z >= 3 Then
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_R_E1(d + 1, 5 + k) * (1 - PVDegradFactor) ^ (z - 1)
'                                Else
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_R_E1(d + 1, 5 + k)
'                                End If
'                            Case "S"
'                                If z >= 3 Then
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_S_E1(d + 1, 5 + k) * (1 - PVDegradFactor) ^ (z - 1)
'                                Else
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_S_E1(d + 1, 5 + k)
'                                End If
'                            Case "T"
'                                If z >= 3 Then
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_T_E1(d + 1, 5 + k) * (1 - PVDegradFactor) ^ (z - 1)
'                                Else
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_T_E1(d + 1, 5 + k)
'                                End If
'                            Case "V"
'                                If z >= 3 Then
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_V_E1(d + 1, 5 + k) * (1 - PVDegradFactor) ^ (z - 1)
'                                Else
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_V_E1(d + 1, 5 + k)
'                                End If
'                            Case "W"
'                                If z >= 3 Then
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_W_E1(d + 1, 5 + k) * (1 - PVDegradFactor) ^ (z - 1)
'                                Else
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_W_E1(d + 1, 5 + k)
'                                End If
'                            Case "X"
'                                If z >= 3 Then
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_X_E1(d + 1, 5 + k) * (1 - PVDegradFactor) ^ (z - 1)
'                                Else
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_X_E1(d + 1, 5 + k)
'                                End If
'                            Case "Y"
'                                If z >= 3 Then
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_Y_E1(d + 1, 5 + k) * (1 - PVDegradFactor) ^ (z - 1)
'                                Else
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_Y_E1(d + 1, 5 + k)
'                                End If
'                            Case "Z"
'                                If z >= 3 Then
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_Z_E1(d + 1, 5 + k) * (1 - PVDegradFactor) ^ (z - 1)
'                                Else
'                                    PVElectOutput_E1(k, d, z, j, i) = CZinfo(i - 1, j - 1).SysSize * PV_Load_Z_E1(d + 1, 5 + k)
'                                End If
'                        End Select
'                    Next k
'                Next d
'            Next z
'        Next j
'    Next i
                                
'    For i = 0 To 364
'        For j = 0 To 23
'            Worksheets("Sheet1").Range("B4").Offset(i, j) = PVElectOutput_E1(i, j, 0, 0, 0, 0)
'            Worksheets("Sheet1").Range("AB4").Offset(i, j) = PVElectOutput_E1(i, j, 29, 0, 0, 0)
'        Next j
'    Next i
    
'    For i = 0 To 4     'check if calculation working correctly
'         For j = 0 To 2
'            Worksheets("Sheet3").Range("A1").Offset(i, j) = e1_summer_rateschd(i, j, 0)
'            Worksheets("Sheet3").Range("N1").Offset(i, j) = e1_winter_rateschd(i, j, 0)
'        Next j
'    Next i

    
End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Arrays are limited by available memory. Having 6 dimensions and using Doubles I would suspect yours is pretty big, depending on the values of the two variables. How you even think of a 6D array is beyond me!
 
Upvote 0
Arrays are limited by available memory. Having 6 dimensions and using Doubles I would suspect yours is pretty big, depending on the values of the two variables. How you even think of a 6D array is beyond me!

Hi rorya,

Thanks for the reply. The array that I am having the problem with would have the following dimensions: 1 to 365, 1 to 24, 1 to 30, 1 to 10, 1 to 4, 1 to 4.
I had IT increase my virtual memory to 8GB but the error still persists.

It is challenging thinking about a 6D array but there is enough context to make it meaningful (# of days, # of hour in day, system life, analysis period, tier level, zone.

do you have any suggestions as to how i can resolve this error?:confused:
 
Upvote 0
Do you actually have data in all, or most, of the array?
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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