Thema Datum  Von Nutzer Rating
Antwort
07.03.2020 10:44:59 Guest
Solved
07.03.2020 10:53:27 Gast77648
NotSolved
07.03.2020 11:01:51 guest
NotSolved
Blau 2 dimensional array in NPV formula
07.03.2020 11:52:05 Gast52116
NotSolved
07.03.2020 10:58:26 Gast7777
NotSolved

Ansicht des Beitrags:
Von:
Gast52116
Datum:
07.03.2020 11:52:05
Views:
469
Rating: Antwort:
  Ja
Thema:
2 dimensional array in NPV formula

You can use a nested array. An easy way to do that, is using the Dictionary-Object.

Option Explicit

Sub test()
  
  Dim list      As Variant
  Dim listNPVs  As Variant
  Dim i         As Long
  Dim j         As Long
  
  Set list = CreateObject("Scripting.Dictionary")
  
  j = 0
  Do While j < 3
    
    Set listNPVs = CreateObject("Scripting.Dictionary")
    
    For i = 0 To 3 'example
      'generate some values
      ' set sign by i >>  -(i Mod 2) -> 0 or -1
      listNPVs.Add item:=((i + j) * 1000 * -(i Mod 2)), key:="_K" & listNPVs.Count
    Next
    
    'add the list of values (basically a 1-dim array) to the list
    list.Add item:=listNPVs.items(), key:="_K" & list.Count
    
    j = j + 1
  Loop
  
  list = list.items() 'get (nested) array from object
  
  For i = 0 To UBound(list)
    
    listNPVs = list(i) 'this is a 1-dim array
    
    'output to immediate window (see vba menu: view)
    Debug.Print "idx_" & i & ":", Join(listNPVs, ", ")
    
  Next
  
End Sub

Without knowing the structure of your data, it is not possible to give you more tips.

 

BR


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
07.03.2020 10:44:59 Guest
Solved
07.03.2020 10:53:27 Gast77648
NotSolved
07.03.2020 11:01:51 guest
NotSolved
Blau 2 dimensional array in NPV formula
07.03.2020 11:52:05 Gast52116
NotSolved
07.03.2020 10:58:26 Gast7777
NotSolved