title: Parsing all prices of same field name if found in sheet from json data vba in a listbox and let user choose
body: <p>So I have some json formatted data, in which an article name (the field in my case is &quot;description courte&quot;) can be used multiple times and have a different price each time, I want to get those prices and display them in a <code>listbox</code> and let the user pick which one to parse in the column &quot;price&quot; which is <code>found.offset(0,3)</code>. Note that I only search for fields that exist in the <code>Range(&quot;G:G&quot;)</code> This is what I did so far :</p>
  <p>This code is returning an error : <code>index does not belong in the selection</code> (sorry if translated badly) at the</p>
  <blockquote>
  <p>Set Found = Range(&quot;G:G&quot;).Find(ArtDict.Items()(Index).Name)</p>
  </blockquote>
  <p><strong>Code example</strong></p>
  <pre><code>Sub prix()
  Dim http As New WinHttpRequest
  Dim resp As String
  Dim url As String
  
  url = &quot;https://api.airtable.com/v0/appY6Wo3AmLHqHkjr/Materiaux?api_key=key_here&quot; &amp; Fields
  http.Open &quot;GET&quot;, url, False
  http.Send
  Dim JSON As Object
  Dim Found As Range
  Dim ArtDict As New Dictionary, Article As class_Article
  Dim Index As Long, count As Long
  Set JSON = JsonConverter.ParseJson(http.ResponseText)
      For Index = 1 To JSON(&quot;records&quot;).count
      Set Found = Range(&quot;G:G&quot;).Find(ArtDict.Items()(Index).Name)
          If Not ArtDict.Exists(JSON(&quot;records&quot;)(Index)(&quot;fields&quot;)(&quot;description courte&quot;)) Then
              'If this article doesn't exist in the article dictionary, then create the article object and add it to the dictionary
              Set Article = New class_Article
              Article.Name = JSON(&quot;records&quot;)(Index)(&quot;fields&quot;)(&quot;description courte&quot;)
              Article.ParsePrice JSON(&quot;records&quot;)(Index)(&quot;fields&quot;)(&quot;prix unitaire HT&quot;)
              Debug.Print Article.Name, Article.HighPrice, Article.LowPrice
              ArtDict.Add Article.Name, Article
          Else
              Set Article = ArtDict(JSON(&quot;records&quot;)(Index)(&quot;fields&quot;)(&quot;description courte&quot;))
              Article.ParsePrice JSON(&quot;records&quot;)(Index)(&quot;fields&quot;)(&quot;prix unitaire HT&quot;)
              Debug.Print Article.Name, Article.HighPrice, Article.LowPrice
              Set ArtDict(JSON(&quot;records&quot;)(Index)(&quot;fields&quot;)(&quot;description courte&quot;)) = Article
          End If
          If Not Found Is Nothing Then
          count = Found.Offset(0, 4).Value + 1
          If count &gt; 1 Then
          UserForm1.Show
          UserForm1.ListBox1.AddItem (Article.HighPrice)
          UserForm1.ListBox1.AddItem (Article.LowPrice)
          Found.Offset(0, 3) = UserForm1.ListBox1.Value
          End If
          End If
      Next Index
  End Sub
  </code></pre>
  <p><strong>JSON SAMPLE</strong></p>
  <pre><code>{
    &quot;records&quot;: [
      {
        &quot;id&quot;: &quot;rec0MS66BnYY0vK32&quot;,
        &quot;fields&quot;: {
          &quot;id&quot;: 124,
          &quot;article&quot;: &quot;osmo 24m2 3062MAT 0.75L&quot;,
          &quot;categorie&quot;: [
            &quot;recvw95DBiWvk3zaH&quot;
          ],
          &quot;udv&quot;: 1,
          &quot;unité&quot;: [
            &quot;recYQ9wpLDgNDk5BW&quot;
          ],
          &quot;prix HT de l'udv&quot;: 29.09,
          &quot;date d'achat&quot;: &quot;2019-08-01&quot;,
          &quot;distributeur&quot;: &quot;cotet mtp&quot;,
          &quot;reference distributeur&quot;: &quot;OSMO-ORI-0.75-M&quot;,
          &quot;id facture&quot;: &quot;FA19036300&quot;,
          &quot;created on&quot;: &quot;2020-02-07&quot;,
          &quot;by&quot;: &quot;remyvignaux&quot;,
          &quot;description courte&quot;: &quot;osmo 3062MAT&quot;,
          &quot;prix unitaire HT&quot;: 29.09
        },
        &quot;createdTime&quot;: &quot;2021-02-28T20:53:00.000Z&quot;
      },....etc 
  </code></pre>
  <p><strong>CLASS_ARTICLE</strong></p>
  <pre><code>Option Explicit
  
  Public Name As String
  Public HighPrice As Currency
  Public LowPrice As Currency
  
  Private Sub Class_Initialize()
      HighPrice = -922337203685477.5807@ 'Set value to lowest possible value
      LowPrice = 922337203685477.5807@ 'Set value to the highest possible value
  End Sub
  
  Public Function ParsePrice(ByVal NewPrice As Currency) As Boolean
      HighPrice = IIf(NewPrice &gt; HighPrice, NewPrice, HighPrice)
      LowPrice = IIf(NewPrice &lt; LowPrice, NewPrice, LowPrice)
  End Function
  </code></pre>