Add items to Array in DictionaryHow to merge two dictionaries in a single expression?What is the best way to iterate over a dictionary?Create ArrayList from arrayHow to insert an item into an array at a specific index (JavaScript)?How do I sort a dictionary by value?Add new keys to a dictionary?Check if a given key already exists in a dictionaryIterating over dictionaries using 'for' loopsHow do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?

Why aren't (poly-)cotton tents more popular?

What is this opening trap called, and how should I play afterwards? How can I refute the gambit, and play if I accept it?

What is an agent in Artificial Intelligence?

Does the UK have a written constitution?

How often can a PC check with passive perception during a combat turn?

Intuitively, why does putting capacitors in series decrease the equivalent capacitance?

Inverse-quotes-quine

How come I was asked by a CBP officer why I was in the US?

Story-based adventure with functions and relationships

How to get cool night-vision without lame drawbacks?

Layout of complex table

Swapping rooks in a 4x4 board

Counting occurrence of words in table is slow

What's the difference between 予定 (Yotei) and 計画 (keikaku)?

Can a US President have someone sent to prison?

How risky is real estate?

How to append a matrix element by element?

In the Marvel universe, can a human have a baby with any non-human?

Is it OK to bottle condition using previously contaminated bottles?

How should I behave to assure my friends that I am not after their money?

How well known and how commonly used was Huffman coding in 1979?

Do equal angles necessarily mean a polygon is regular?

MH370 blackbox - is it still possible to retrieve data from it?

Using “sparkling” as a diminutive of “spark” in a poem



Add items to Array in Dictionary


How to merge two dictionaries in a single expression?What is the best way to iterate over a dictionary?Create ArrayList from arrayHow to insert an item into an array at a specific index (JavaScript)?How do I sort a dictionary by value?Add new keys to a dictionary?Check if a given key already exists in a dictionaryIterating over dictionaries using 'for' loopsHow do I remove a particular element from an array in JavaScript?For-each over an array in JavaScript?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a dictionary and want to add new strings to the items. My idea is to create a list of strings as item for each key.



My code is so far:



Sub AccountEntitlements()

Dim sh1 As Worksheet
Dim acc As Worksheet
Dim arr() As Variant
Dim d As Variant
Dim i As Long
Dim count As Long

Set sh1 = Sheets("Sheet1")
Set acc = Sheets("accountsentitlements")
Set d = CreateObject("Scripting.Dictionary")

arr = sh1.Range("D:F")

For i = LBound(arr) To UBound(arr)
If d.Exists(arr(i, 3)) Then
ReDim Preserve arr(UBound(arr) + 1) '<- Error line
d(arr(i, 3)) = Array(arr(i, 1))
Else
d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
End If

Next i

For count = 1 To d.count - 1
acc.Cells(count + 1, "D").Value = UCase(d.Keys()(count))
acc.Cells(count + 1, "E").Value = d.Items()(count)
Next count

End Sub


The error message is Run-time error '9': Subscript out of range.



The important code block is



For i = LBound(arr) To UBound(arr)
If d.Exists(arr(i, 3)) Then
ReDim Preserve arr(UBound(arr) + 1) '<- Error line
d(arr(i, 3)) = Array(arr(i, 1))
Else
d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
End If


The key of a dictionary is the user account and the items should be their membership groups.
Example:




Key= ABCD , Item= Entitlement1, Entitlement2, etc.




How can the item array be extended and include previous entries?










share|improve this question

















  • 1





    Use a Dictionary or Collection instead of an array to hold the membership groups. And why create such a large array to loop through in the first place?

    – Ron Rosenfeld
    Mar 25 at 10:36







  • 2





    The error is because you can only Redim Preserve the last element of a multidimensional array. Since you already arr= Range("D:F"), and your Redim Preserve arr(...` statement must fail. It is NOT acting on the array in the Dictionary.

    – Ron Rosenfeld
    Mar 25 at 10:42












  • @RonRosenfeld, what do you mean with 'such a large array'? How would you split the array?

    – Alex_P
    Mar 25 at 10:59






  • 1





    arr = Range("D:F") creates an array of dimensions (1 to 1048576, 1 to 4). Do you have that many items in your database? For a good discussion, see the late Chip Pearsons article on Arrays and Ranges in VBA

    – Ron Rosenfeld
    Mar 25 at 11:02












  • @RonRosenfeld, I have 81.000 rows. Thank you for the link. I will check it out.

    – Alex_P
    Mar 25 at 11:04


















0















I have a dictionary and want to add new strings to the items. My idea is to create a list of strings as item for each key.



My code is so far:



Sub AccountEntitlements()

Dim sh1 As Worksheet
Dim acc As Worksheet
Dim arr() As Variant
Dim d As Variant
Dim i As Long
Dim count As Long

Set sh1 = Sheets("Sheet1")
Set acc = Sheets("accountsentitlements")
Set d = CreateObject("Scripting.Dictionary")

arr = sh1.Range("D:F")

For i = LBound(arr) To UBound(arr)
If d.Exists(arr(i, 3)) Then
ReDim Preserve arr(UBound(arr) + 1) '<- Error line
d(arr(i, 3)) = Array(arr(i, 1))
Else
d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
End If

Next i

For count = 1 To d.count - 1
acc.Cells(count + 1, "D").Value = UCase(d.Keys()(count))
acc.Cells(count + 1, "E").Value = d.Items()(count)
Next count

End Sub


The error message is Run-time error '9': Subscript out of range.



The important code block is



For i = LBound(arr) To UBound(arr)
If d.Exists(arr(i, 3)) Then
ReDim Preserve arr(UBound(arr) + 1) '<- Error line
d(arr(i, 3)) = Array(arr(i, 1))
Else
d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
End If


The key of a dictionary is the user account and the items should be their membership groups.
Example:




Key= ABCD , Item= Entitlement1, Entitlement2, etc.




How can the item array be extended and include previous entries?










share|improve this question

















  • 1





    Use a Dictionary or Collection instead of an array to hold the membership groups. And why create such a large array to loop through in the first place?

    – Ron Rosenfeld
    Mar 25 at 10:36







  • 2





    The error is because you can only Redim Preserve the last element of a multidimensional array. Since you already arr= Range("D:F"), and your Redim Preserve arr(...` statement must fail. It is NOT acting on the array in the Dictionary.

    – Ron Rosenfeld
    Mar 25 at 10:42












  • @RonRosenfeld, what do you mean with 'such a large array'? How would you split the array?

    – Alex_P
    Mar 25 at 10:59






  • 1





    arr = Range("D:F") creates an array of dimensions (1 to 1048576, 1 to 4). Do you have that many items in your database? For a good discussion, see the late Chip Pearsons article on Arrays and Ranges in VBA

    – Ron Rosenfeld
    Mar 25 at 11:02












  • @RonRosenfeld, I have 81.000 rows. Thank you for the link. I will check it out.

    – Alex_P
    Mar 25 at 11:04














0












0








0








I have a dictionary and want to add new strings to the items. My idea is to create a list of strings as item for each key.



My code is so far:



Sub AccountEntitlements()

Dim sh1 As Worksheet
Dim acc As Worksheet
Dim arr() As Variant
Dim d As Variant
Dim i As Long
Dim count As Long

Set sh1 = Sheets("Sheet1")
Set acc = Sheets("accountsentitlements")
Set d = CreateObject("Scripting.Dictionary")

arr = sh1.Range("D:F")

For i = LBound(arr) To UBound(arr)
If d.Exists(arr(i, 3)) Then
ReDim Preserve arr(UBound(arr) + 1) '<- Error line
d(arr(i, 3)) = Array(arr(i, 1))
Else
d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
End If

Next i

For count = 1 To d.count - 1
acc.Cells(count + 1, "D").Value = UCase(d.Keys()(count))
acc.Cells(count + 1, "E").Value = d.Items()(count)
Next count

End Sub


The error message is Run-time error '9': Subscript out of range.



The important code block is



For i = LBound(arr) To UBound(arr)
If d.Exists(arr(i, 3)) Then
ReDim Preserve arr(UBound(arr) + 1) '<- Error line
d(arr(i, 3)) = Array(arr(i, 1))
Else
d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
End If


The key of a dictionary is the user account and the items should be their membership groups.
Example:




Key= ABCD , Item= Entitlement1, Entitlement2, etc.




How can the item array be extended and include previous entries?










share|improve this question














I have a dictionary and want to add new strings to the items. My idea is to create a list of strings as item for each key.



My code is so far:



Sub AccountEntitlements()

Dim sh1 As Worksheet
Dim acc As Worksheet
Dim arr() As Variant
Dim d As Variant
Dim i As Long
Dim count As Long

Set sh1 = Sheets("Sheet1")
Set acc = Sheets("accountsentitlements")
Set d = CreateObject("Scripting.Dictionary")

arr = sh1.Range("D:F")

For i = LBound(arr) To UBound(arr)
If d.Exists(arr(i, 3)) Then
ReDim Preserve arr(UBound(arr) + 1) '<- Error line
d(arr(i, 3)) = Array(arr(i, 1))
Else
d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
End If

Next i

For count = 1 To d.count - 1
acc.Cells(count + 1, "D").Value = UCase(d.Keys()(count))
acc.Cells(count + 1, "E").Value = d.Items()(count)
Next count

End Sub


The error message is Run-time error '9': Subscript out of range.



The important code block is



For i = LBound(arr) To UBound(arr)
If d.Exists(arr(i, 3)) Then
ReDim Preserve arr(UBound(arr) + 1) '<- Error line
d(arr(i, 3)) = Array(arr(i, 1))
Else
d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
End If


The key of a dictionary is the user account and the items should be their membership groups.
Example:




Key= ABCD , Item= Entitlement1, Entitlement2, etc.




How can the item array be extended and include previous entries?







arrays excel vba dictionary






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 10:20









Alex_PAlex_P

3451 gold badge4 silver badges15 bronze badges




3451 gold badge4 silver badges15 bronze badges







  • 1





    Use a Dictionary or Collection instead of an array to hold the membership groups. And why create such a large array to loop through in the first place?

    – Ron Rosenfeld
    Mar 25 at 10:36







  • 2





    The error is because you can only Redim Preserve the last element of a multidimensional array. Since you already arr= Range("D:F"), and your Redim Preserve arr(...` statement must fail. It is NOT acting on the array in the Dictionary.

    – Ron Rosenfeld
    Mar 25 at 10:42












  • @RonRosenfeld, what do you mean with 'such a large array'? How would you split the array?

    – Alex_P
    Mar 25 at 10:59






  • 1





    arr = Range("D:F") creates an array of dimensions (1 to 1048576, 1 to 4). Do you have that many items in your database? For a good discussion, see the late Chip Pearsons article on Arrays and Ranges in VBA

    – Ron Rosenfeld
    Mar 25 at 11:02












  • @RonRosenfeld, I have 81.000 rows. Thank you for the link. I will check it out.

    – Alex_P
    Mar 25 at 11:04













  • 1





    Use a Dictionary or Collection instead of an array to hold the membership groups. And why create such a large array to loop through in the first place?

    – Ron Rosenfeld
    Mar 25 at 10:36







  • 2





    The error is because you can only Redim Preserve the last element of a multidimensional array. Since you already arr= Range("D:F"), and your Redim Preserve arr(...` statement must fail. It is NOT acting on the array in the Dictionary.

    – Ron Rosenfeld
    Mar 25 at 10:42












  • @RonRosenfeld, what do you mean with 'such a large array'? How would you split the array?

    – Alex_P
    Mar 25 at 10:59






  • 1





    arr = Range("D:F") creates an array of dimensions (1 to 1048576, 1 to 4). Do you have that many items in your database? For a good discussion, see the late Chip Pearsons article on Arrays and Ranges in VBA

    – Ron Rosenfeld
    Mar 25 at 11:02












  • @RonRosenfeld, I have 81.000 rows. Thank you for the link. I will check it out.

    – Alex_P
    Mar 25 at 11:04








1




1





Use a Dictionary or Collection instead of an array to hold the membership groups. And why create such a large array to loop through in the first place?

– Ron Rosenfeld
Mar 25 at 10:36






Use a Dictionary or Collection instead of an array to hold the membership groups. And why create such a large array to loop through in the first place?

– Ron Rosenfeld
Mar 25 at 10:36





2




2





The error is because you can only Redim Preserve the last element of a multidimensional array. Since you already arr= Range("D:F"), and your Redim Preserve arr(...` statement must fail. It is NOT acting on the array in the Dictionary.

– Ron Rosenfeld
Mar 25 at 10:42






The error is because you can only Redim Preserve the last element of a multidimensional array. Since you already arr= Range("D:F"), and your Redim Preserve arr(...` statement must fail. It is NOT acting on the array in the Dictionary.

– Ron Rosenfeld
Mar 25 at 10:42














@RonRosenfeld, what do you mean with 'such a large array'? How would you split the array?

– Alex_P
Mar 25 at 10:59





@RonRosenfeld, what do you mean with 'such a large array'? How would you split the array?

– Alex_P
Mar 25 at 10:59




1




1





arr = Range("D:F") creates an array of dimensions (1 to 1048576, 1 to 4). Do you have that many items in your database? For a good discussion, see the late Chip Pearsons article on Arrays and Ranges in VBA

– Ron Rosenfeld
Mar 25 at 11:02






arr = Range("D:F") creates an array of dimensions (1 to 1048576, 1 to 4). Do you have that many items in your database? For a good discussion, see the late Chip Pearsons article on Arrays and Ranges in VBA

– Ron Rosenfeld
Mar 25 at 11:02














@RonRosenfeld, I have 81.000 rows. Thank you for the link. I will check it out.

– Alex_P
Mar 25 at 11:04






@RonRosenfeld, I have 81.000 rows. Thank you for the link. I will check it out.

– Alex_P
Mar 25 at 11:04













2 Answers
2






active

oldest

votes


















1














Among other problems:



You can only ReDim the last element of a multi-dimensional array.



Your line



arr = sh1.Range("D:F")


will create a 1-based 2D array: arr(1 to 1048576, 1 to 4). If you have a database with over 4*10^6 elements, you might want to consider a different tool.



So a valid command might be



Redim Preserve arr(1 to ubound(arr,1), 1 to ubound(arr,2)+1)


But that's not what your doing. To accomplish what you want to do, try something like this:



For i = LBound(arr) To UBound(arr)
If d.Exists(arr(i, 3)) Then
X = d(arr(i, 3))
ReDim Preserve X(UBound(X, 1) + 1)
X(UBound(X, 1)) = arr(i, 1)
d(arr(i, 3)) = X
Else
d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
End If
Next i


But why not just use a Dictionary or Collection to hold your list of items. Then you don't have to worry at all about resizing your array.






share|improve this answer
































    0














    Thank you very much for your assistance (@Ron Rosenfeld)!



    Below is my final code part.



    For i = LBound(arr) To UBound(arr)
    If d.Exists(arr(i, 3)) Then
    d(arr(i, 3)) = d.Item(arr(i, 3)) & "," & arr(i, 1)
    Else
    d.Add Key:=arr(i, 3), Item:=arr(i, 1)
    End If
    Next i


    I was still testing whether I should concatenate the strings with & "," & or with the JOIN() function but decided eventually for the first option.



    Regarding my array size, I added a row counter to fit the length of the array. lrow = sh1.Cells(Rows.count, "D").End(xlUp).Row.






    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55335581%2fadd-items-to-array-in-dictionary%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Among other problems:



      You can only ReDim the last element of a multi-dimensional array.



      Your line



      arr = sh1.Range("D:F")


      will create a 1-based 2D array: arr(1 to 1048576, 1 to 4). If you have a database with over 4*10^6 elements, you might want to consider a different tool.



      So a valid command might be



      Redim Preserve arr(1 to ubound(arr,1), 1 to ubound(arr,2)+1)


      But that's not what your doing. To accomplish what you want to do, try something like this:



      For i = LBound(arr) To UBound(arr)
      If d.Exists(arr(i, 3)) Then
      X = d(arr(i, 3))
      ReDim Preserve X(UBound(X, 1) + 1)
      X(UBound(X, 1)) = arr(i, 1)
      d(arr(i, 3)) = X
      Else
      d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
      End If
      Next i


      But why not just use a Dictionary or Collection to hold your list of items. Then you don't have to worry at all about resizing your array.






      share|improve this answer





























        1














        Among other problems:



        You can only ReDim the last element of a multi-dimensional array.



        Your line



        arr = sh1.Range("D:F")


        will create a 1-based 2D array: arr(1 to 1048576, 1 to 4). If you have a database with over 4*10^6 elements, you might want to consider a different tool.



        So a valid command might be



        Redim Preserve arr(1 to ubound(arr,1), 1 to ubound(arr,2)+1)


        But that's not what your doing. To accomplish what you want to do, try something like this:



        For i = LBound(arr) To UBound(arr)
        If d.Exists(arr(i, 3)) Then
        X = d(arr(i, 3))
        ReDim Preserve X(UBound(X, 1) + 1)
        X(UBound(X, 1)) = arr(i, 1)
        d(arr(i, 3)) = X
        Else
        d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
        End If
        Next i


        But why not just use a Dictionary or Collection to hold your list of items. Then you don't have to worry at all about resizing your array.






        share|improve this answer



























          1












          1








          1







          Among other problems:



          You can only ReDim the last element of a multi-dimensional array.



          Your line



          arr = sh1.Range("D:F")


          will create a 1-based 2D array: arr(1 to 1048576, 1 to 4). If you have a database with over 4*10^6 elements, you might want to consider a different tool.



          So a valid command might be



          Redim Preserve arr(1 to ubound(arr,1), 1 to ubound(arr,2)+1)


          But that's not what your doing. To accomplish what you want to do, try something like this:



          For i = LBound(arr) To UBound(arr)
          If d.Exists(arr(i, 3)) Then
          X = d(arr(i, 3))
          ReDim Preserve X(UBound(X, 1) + 1)
          X(UBound(X, 1)) = arr(i, 1)
          d(arr(i, 3)) = X
          Else
          d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
          End If
          Next i


          But why not just use a Dictionary or Collection to hold your list of items. Then you don't have to worry at all about resizing your array.






          share|improve this answer















          Among other problems:



          You can only ReDim the last element of a multi-dimensional array.



          Your line



          arr = sh1.Range("D:F")


          will create a 1-based 2D array: arr(1 to 1048576, 1 to 4). If you have a database with over 4*10^6 elements, you might want to consider a different tool.



          So a valid command might be



          Redim Preserve arr(1 to ubound(arr,1), 1 to ubound(arr,2)+1)


          But that's not what your doing. To accomplish what you want to do, try something like this:



          For i = LBound(arr) To UBound(arr)
          If d.Exists(arr(i, 3)) Then
          X = d(arr(i, 3))
          ReDim Preserve X(UBound(X, 1) + 1)
          X(UBound(X, 1)) = arr(i, 1)
          d(arr(i, 3)) = X
          Else
          d.Add Key:=arr(i, 3), Item:=Array(arr(i, 1))
          End If
          Next i


          But why not just use a Dictionary or Collection to hold your list of items. Then you don't have to worry at all about resizing your array.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 25 at 11:00

























          answered Mar 25 at 10:34









          Ron RosenfeldRon Rosenfeld

          25.6k4 gold badges17 silver badges41 bronze badges




          25.6k4 gold badges17 silver badges41 bronze badges























              0














              Thank you very much for your assistance (@Ron Rosenfeld)!



              Below is my final code part.



              For i = LBound(arr) To UBound(arr)
              If d.Exists(arr(i, 3)) Then
              d(arr(i, 3)) = d.Item(arr(i, 3)) & "," & arr(i, 1)
              Else
              d.Add Key:=arr(i, 3), Item:=arr(i, 1)
              End If
              Next i


              I was still testing whether I should concatenate the strings with & "," & or with the JOIN() function but decided eventually for the first option.



              Regarding my array size, I added a row counter to fit the length of the array. lrow = sh1.Cells(Rows.count, "D").End(xlUp).Row.






              share|improve this answer



























                0














                Thank you very much for your assistance (@Ron Rosenfeld)!



                Below is my final code part.



                For i = LBound(arr) To UBound(arr)
                If d.Exists(arr(i, 3)) Then
                d(arr(i, 3)) = d.Item(arr(i, 3)) & "," & arr(i, 1)
                Else
                d.Add Key:=arr(i, 3), Item:=arr(i, 1)
                End If
                Next i


                I was still testing whether I should concatenate the strings with & "," & or with the JOIN() function but decided eventually for the first option.



                Regarding my array size, I added a row counter to fit the length of the array. lrow = sh1.Cells(Rows.count, "D").End(xlUp).Row.






                share|improve this answer

























                  0












                  0








                  0







                  Thank you very much for your assistance (@Ron Rosenfeld)!



                  Below is my final code part.



                  For i = LBound(arr) To UBound(arr)
                  If d.Exists(arr(i, 3)) Then
                  d(arr(i, 3)) = d.Item(arr(i, 3)) & "," & arr(i, 1)
                  Else
                  d.Add Key:=arr(i, 3), Item:=arr(i, 1)
                  End If
                  Next i


                  I was still testing whether I should concatenate the strings with & "," & or with the JOIN() function but decided eventually for the first option.



                  Regarding my array size, I added a row counter to fit the length of the array. lrow = sh1.Cells(Rows.count, "D").End(xlUp).Row.






                  share|improve this answer













                  Thank you very much for your assistance (@Ron Rosenfeld)!



                  Below is my final code part.



                  For i = LBound(arr) To UBound(arr)
                  If d.Exists(arr(i, 3)) Then
                  d(arr(i, 3)) = d.Item(arr(i, 3)) & "," & arr(i, 1)
                  Else
                  d.Add Key:=arr(i, 3), Item:=arr(i, 1)
                  End If
                  Next i


                  I was still testing whether I should concatenate the strings with & "," & or with the JOIN() function but decided eventually for the first option.



                  Regarding my array size, I added a row counter to fit the length of the array. lrow = sh1.Cells(Rows.count, "D").End(xlUp).Row.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 26 at 8:58









                  Alex_PAlex_P

                  3451 gold badge4 silver badges15 bronze badges




                  3451 gold badge4 silver badges15 bronze badges



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55335581%2fadd-items-to-array-in-dictionary%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                      155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해