Sub DES_Systems()
Dim Station_ID_S As Long, Station_ID_Z As Long, ArProfit As Variant, b As Long, c As Long, lLZeile As Long, a As Long, Y As Long, ArMaxPrice(1 To 10000) As Long
Dim ArStations As Variant, ArCopy As Variant, x As Long
Call Add_DES_Stations
Worksheets("Pre_Select").Range("Y2:Y1001").ClearContents
'Systemname schreiben
Station_ID_S = Worksheets("Werte").Cells(3, 2).Value
For Y = 1 To Worksheets("Werte").Cells(79, 8).Value
DoEvents
ReDim ArProfit(AzGoods)
Station_ID_Z = Worksheets("Pre_Select").Cells(1 + Y, 18).Value
For c = 3 To AzGoods + 2
DoEvents
If ArData_Buy(c, Station_ID_S + 2) <> 0 And ArData_Buy(c, Station_ID_S + 2) <> "" And ArData_Sell(c, Station_ID_Z + 2) <> 0 And ArData_Sell(c, Station_ID_Z + 2) <> "" And ArData_Sell(c, Station_ID_Z + 2) - ArData_Buy(c, Station_ID_S + 2) > 0 Then
ArProfit(c - 2) = ArData_Sell(c, Station_ID_Z + 2) - ArData_Buy(c, Station_ID_S + 2)
End If
Next c
ArMaxPrice(Y) = WorksheetFunction.Max(ArProfit)
Erase ArProfit
Next Y
With Application.WorksheetFunction
Worksheets("Pre_Select").Range("Y2:Y" & Worksheets("Werte").Cells(40, 2).Value + 1) = .Transpose(ArMaxPrice)
End With
Worksheets("Systems").Activate
Worksheets("Systems").Range("L2:V20001").ClearContents
Worksheets("Systems").Range("L2:V" & Worksheets("Werte").Cells(40, 2).Value + 1).Value = Worksheets("Pre_Select").Range("P2:Z" & Worksheets("Werte").Cells(40, 2).Value + 1).Value
Call Add_DES_Stations_UR
ActiveWorkbook.Worksheets("Systems").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Systems").Sort.SortFields.Add Key:=Range( _
"U2:U20001"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Systems").Sort
.SetRange Range("L1:V20001")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
If Worksheets("DB_Config").Cells(2, 14).Value = True Then
If Worksheets("Systems").Cells(2, 12).Value <> "" Then
For a = 1 To AzRegStations - 1
If (Ar_Type(Ar_DBRegStations(Worksheets("Systems").Cells(1 + a, 14).Value, 10), 3) = "L" And Worksheets("Data").Cells(111, 2).Value = True) Or (Ar_Type(Ar_DBRegStations(Worksheets("Systems").Cells(1 + a, 14).Value, 10), 3) = "M" And Worksheets("Data").Cells(110, 2).Value = True = True) Or (Ar_Type(Ar_DBRegStations(Worksheets("Systems").Cells(1 + a, 14).Value, 10), 3) = "S" And Worksheets("Data").Cells(109, 2).Value = True) Then
Worksheets("Werte").Cells(12, 2).Value = Worksheets("Systems").Cells(a + 1, 12).Value
Worksheets("Werte").Cells(13, 2).Value = Worksheets("Systems").Cells(a + 1, 14).Value
a = AzRegStations - 1
End If
Next a
Worksheets("DB_Config").Cells(2, 5).Value = Worksheets("Werte").Cells(12, 2).Value
Worksheets("DB_Config").Cells(2, 6).Value = Worksheets("Werte").Cells(13, 2).Value
Call Check_Size
If Main_Panel = "TOP" Then
Panel_Menu_top.DES_Label.Caption = "AUTO DESTINATION"
Panel_Menu_top.DES_Info.Caption = Worksheets("Werte").Cells(14, 2).Value & " : " & Worksheets("Werte").Cells(15, 2).Value
Panel_Menu_top.DES_Juris.Caption = Worksheets("Werte").Cells(16, 2).Value & " SPACE"
Panel_Menu_top.DES_Eco.Caption = Worksheets("Werte").Cells(17, 2).Value
If Worksheets("Werte").Cells(14, 2).Value = Worksheets("ShipLog").Cells(Worksheets("Werte").Cells(74, 3).Value + 1, 2).Value Then
Panel_Menu_top.DES_Distance.Caption = Worksheets("Werte").Cells(18, 5).Text & " LS"
Else
Panel_Menu_top.DES_Distance.Caption = Worksheets("Werte").Cells(16, 5).Value & " LY"
End If
Else
Panel_Menu_bottom.DES_Label.Caption = "AUTO DESTINATION"
Panel_Menu_bottom.DES_Info.Caption = Worksheets("Werte").Cells(14, 2).Value & " : " & Worksheets("Werte").Cells(15, 2).Value
Panel_Menu_bottom.DES_Juris.Caption = Worksheets("Werte").Cells(16, 2).Value & " SPACE"
Panel_Menu_bottom.DES_Eco.Caption = Worksheets("Werte").Cells(17, 2).Value
If Worksheets("Werte").Cells(14, 2).Value = Worksheets("ShipLog").Cells(Worksheets("Werte").Cells(74, 3).Value + 1, 2).Value Then
Panel_Menu_bottom.DES_Distance.Caption = Worksheets("Werte").Cells(18, 5).Text & " LS"
Else
Panel_Menu_bottom.DES_Distance.Caption = Worksheets("Werte").Cells(16, 5).Value & " LY"
End If
End If
Panel_Trade.CB_Route.ListIndex = Worksheets("Werte").Cells(53, 5).Value - 1
Panel_Trade.DES_Label.Caption = "RECOMMENDED STATION"
Else
Worksheets("DB_Config").Cells(2, 14).Value = False
Call save_TCE_ini
If Main_Panel = "TOP" Then
Panel_Menu_top.DES_Label.Caption = "SELECTED DESTINATION"
Else
Panel_Menu_bottom.DES_Label.Caption = "SELECTED DESTINATION"
End If
Panel_Trade.CB_Route.ListIndex = Worksheets("Werte").Cells(53, 5).Value - 1
Panel_Trade.DES_Label.Caption = "SELECTED STATION"
End If
End If
End Sub