Excel VBA Dictionary: How to use the Dictionary (1/4)

Поділитися
Вставка
  • Опубліковано 8 січ 2025

КОМЕНТАРІ • 62

  • @Excelmacromastery
    @Excelmacromastery  5 років тому +7

    Hi everyone. Please enjoy the first video about VBA Dictionary. If you have any comments, please add them below.

  • @turkaykoc8587
    @turkaykoc8587 Рік тому +1

    Your did a very good job, thank you so much for the clear explanations.

  • @ryanquinn1257
    @ryanquinn1257 2 роки тому

    Best excel advice and vids.
    Perfectly solves a problem trying to count duplicates of a list where I don’t want to sort the list, it has to process in order.
    I have a SKU name I pull from JSON data and a file i end up downloading where the download is named SKU name for first then SKU name-1 for the second SKU name -2 so on.
    This allows me to add the SKU as the key, value is duplicateCount starting at 0.
    If the SKU name hasn’t shown up yet add it to dictionary, Otherwise increment up duplicateCount
    If duplicateCount is 0 then keep SKU name as SKU, otherwise SKU-duplicateCount

  • @sakhilengwenya594
    @sakhilengwenya594 4 місяці тому +1

    Please do an example on mapping data using dictionary and arrays

  • @VBAbyMBA
    @VBAbyMBA 3 роки тому +3

    So simple but have so many possibilities.
    Thanks ☺️

  • @trinhthanhlinh150
    @trinhthanhlinh150 5 років тому +1

    Your explanation is trule comprehensive. Thank you Paul!

  • @franciscoaugustovarelaagui2443

    muchas gracias por la clase! Muy claro todo!!

  • @Up4Excel
    @Up4Excel 5 років тому +3

    Very well explained...and I can see there will be plenty of uses so looking forward to the rest of the series

  • @rakeshkumarmadella7955
    @rakeshkumarmadella7955 4 роки тому

    Thank u so much Paul.. I am getting your emails every day.. your channel is very useful .. very nice wonderful great video.. I really loved it sir

  • @MyAudioBookCompilation
    @MyAudioBookCompilation 2 роки тому

    Wow you have a different approach of using and explaining Dictionary. I have been using this for quite sometime but explaining Item like a Value makes it more understandable. I want to learn how to use API and i though your guidance will bring me there. Thank you so much.

  • @gilenomascarenhas6693
    @gilenomascarenhas6693 4 роки тому

    Oh, man... this is pure gold. Thank you, sir.

  • @prakashsrinivasan7840
    @prakashsrinivasan7840 3 роки тому

    Well explained thank you👍👍👍

  • @buithitrami175
    @buithitrami175 5 років тому +1

    Thanks Paul! It has been 2 weeks since your last video. Looking forward to more videos soon 😊

  • @virginiacardinalchildsuppo5090
    @virginiacardinalchildsuppo5090 3 роки тому

    Awesome lecture

  • @wattjock2405
    @wattjock2405 3 роки тому +2

    I am very grateful to your videos and am learning a lot.
    I opened the Watch Window and added dict("Apple") to it as shown in video. The Code, the Watch Window, and the Immediate Window all work fine as I Step through (F8) the Code.
    However; when I then add dict("Orange") to the Watch Window and step through with F8, I get the Error Message that "This Key is already associated with an element of this Collection".
    But... if I use F5 to simply run the code, everything runs and the Immediate Window prints out all the correct Values.
    What am I missing?

    • @Excelmacromastery
      @Excelmacromastery  3 роки тому +2

      This is actually a bug with the Dictionary. If you add an item in the watch window it gets added to the Dictionary. It caught me out a few times before I discovered it.

    • @wattjock2405
      @wattjock2405 3 роки тому

      @@Excelmacromastery ~ thanks... thought I had written the Code incorrectly.
      Yes, I write all of the Code as you present it "for the practice".

  • @sebastienantunes9668
    @sebastienantunes9668 3 місяці тому

    Very useful video !
    I was surprised by following the intellisense
    dict.Add(“Apple”,60)
    does not work
    but if I write
    dict.Add “Apple”,60
    then it's ok
    The intellisense misled me.
    What is the difference between the 2 writings?
    Thanks ...

  • @vikuedutech5061
    @vikuedutech5061 3 роки тому

    Really wonderful and i have made a real dictionary in excel userform ..

  • @thearchibaldtuttle
    @thearchibaldtuttle 5 років тому

    Nice, never used the watch window this way!

    • @Excelmacromastery
      @Excelmacromastery  5 років тому

      Thanks. It's a nice way of demonstrating the values in the variables.

  • @wayneedmondson1065
    @wayneedmondson1065 5 років тому +2

    Hi Paul.. great intro to using a Dictionary.. looking forward to more. I see below you've mentioned about early and late binding. So, if you are going to distribute your code to users who might not have a reference to the Scripting Runtime, then you early bind while you write the code (for Intellisense) and then modify the code to late bind (Dim dict and Set dict=CreateObject("Scripting.Dictionary")) before distribution? That seems like the logical approach..yes? Thanks for the inspiration to think and create. Thumbs up!

    • @Excelmacromastery
      @Excelmacromastery  5 років тому +3

      That's exactly right Wayne. For distribution it is always better to use late binding.

    • @wayneedmondson1065
      @wayneedmondson1065 5 років тому +1

      @@Excelmacromastery Thanks Paul.. loving your videos and UA-cam channel. BTW, on your channel, take a look at the View Full Playlist for Excel VBA Collections. It looks like someone inserted a 6th video into the list.. not related to VBA.. maybe some kind of a hack.. don't want to click on it.. but it definitely looks like it does not belong there. Thought you would want to know and delete it or report it to UA-cam. Thanks again!

    • @Excelmacromastery
      @Excelmacromastery  5 років тому +1

      Thanks Wayne. I removed that video. All is good now.

  • @OmkarUmbre
    @OmkarUmbre 5 років тому

    Hi you shown how to add elements to the dictionary, can you please explain the purpose /use of the added elements.

  • @andyalmanza1517
    @andyalmanza1517 2 роки тому

    Hi, great video. I ran into a problem I'm hoping you can help with. I added the Microsoft Scripting Runtime reference and created my dictionary variable the same way you did. However, the "Add" method is not available for my dictionary, why would that be?

  • @raulleopoldobini6831
    @raulleopoldobini6831 2 роки тому

    Hi! can you teach us how yo create a dictionary of collections of class collections?

  • @dangelorrrr
    @dangelorrrr 5 років тому +2

    Hi Paul - you need to edit your above video description...
    "In this Excel VBA video, we see how to use Class modules objects with Collections. One of the problems with collections is that it can only store one item from a row of data.
    So how to we store data from multiple columns? We use class module objects.
    "

  • @dmp7252
    @dmp7252 3 роки тому

    Is there a spot where we can see what the end-product looks like?

  • @bobkaplan251
    @bobkaplan251 5 років тому +1

    I thank you for explaining this so well as I've wondered for years what it did or was. But, I'm puzzled as to where I might use it. For example, I have a price list with 3,000+ items on it that I use repeatedly. I know the item number (key) so I've just been inputting that in the Excel Find option. Is there maybe some better way to use the dictionary to do this?

    • @Excelmacromastery
      @Excelmacromastery  5 років тому +1

      Good to hear from you Bob.
      If you have a low frequency of finds e.g. manually finding the Excel Find is fine.
      For a high frequency though, the Excel Find is slow. For example, imagine you had a second list of 1000 items and you had to look up these in the first list. Then the dictionary would be very useful.
      You can see some examples at the bottom of this post:
      Excel VBA Dictionary(excelmacromastery.com/vba-dictionary)
      Show less

    • @Kralnor
      @Kralnor 4 роки тому

      One major benefit of using a Dictionary is that lookups take constant time. That is, it doesn't matter how large the Dictionary is, looking up a certain key will always be practically instant.
      This is unlike arrays where you need to scan through the array.

  • @venusflytrap909
    @venusflytrap909 3 роки тому

    Is there a method to apply a Like comparison to the value in the dictionary i.e. Dict item is "Shower" but like comparison would be Shower1 or Shower 2 etc - I have tried with no success adding wildcard to the dict item

  • @H2Dwoat
    @H2Dwoat 5 років тому

    Hi, I saw you added the dictionary from the reference library. Do all users then have to add it to make use of the workbook?

    • @Excelmacromastery
      @Excelmacromastery  5 років тому

      In practise is better to use Late Binding(i.e. CreateObject) instead of the reference when distributing to other users.

  • @virtreal4663
    @virtreal4663 3 роки тому

    How add to dictionary other dictionaries?

  • @savaliyanirav9680
    @savaliyanirav9680 Місяць тому

    My dictionary object always has one empty item in it. Also, I cannot remove that "Item 1" using : If Dict.Exists(" ") Then Dict.Remove " " ....... What is the solution?

  • @UncleChopChop22
    @UncleChopChop22 5 років тому

    Hi thanks for the video.i see It is 1 of 5. Will the other be far away as I noticed others are being released.

    • @Excelmacromastery
      @Excelmacromastery  5 років тому +1

      Hi next Dictionary video will be released in the next 2 or 3 weeks.

    • @UncleChopChop22
      @UncleChopChop22 5 років тому

      @@Excelmacromastery no worries. Look forward. Hope you stick to the vids. Been enjoying them. Easier to watch then some of the other drawn out vids on here.👍

  • @thescharfies3723
    @thescharfies3723 Рік тому

    top !!

  • @arkabose1102
    @arkabose1102 4 роки тому

    what if I want to add multiple values to a key in a dictionary? Like in python, I use key.append(xyz). How to do that in vba dictionary?

    • @ryanquinn1257
      @ryanquinn1257 2 роки тому

      Your dictionary value probably ends up being a variant array or another collection or dictionary depending on use case. That kinda how my nested Jsons end up working

  • @mrbubetube
    @mrbubetube 2 роки тому

    I think the Peter Norton look went out with the 1980s dude

  • @flemsflems4630
    @flemsflems4630 4 роки тому

    How can I write a formula in an excel cell to extract 1 item from the dictionary by using the key? I would think you you write something like this in a cell =(DD.name,key,position) then Apple would be in one cell.

  • @susantakumar8330
    @susantakumar8330 5 років тому

    Hi Paul,
    I used late binding but I am getting object can't be created error message in office 365. Is there any solution? I can't use early binding bcz I need to distribute the Xlam file to my team.

    • @kingpin11111
      @kingpin11111 4 роки тому +1

      Make sure you write
      set dict = CreateObject("Scripting.Dictionary")
      and not just
      set dict = CreateObject("Dictionary")

  • @rrrprogram8667
    @rrrprogram8667 5 років тому

    Keep calm and learn vba

  • @enricomendiola9952
    @enricomendiola9952 3 роки тому

    Hello Sir,
    If I have this kind of data how can I do it using Dictionary:
    Column Headers
    P1 with phone numbers
    P1 Type : Cell or Landline or Voip
    P1 Old: Yes or No
    Phone1, P1 Type, P1 Old, Phone2,
    P1 Type, P2 Old up to Phone10
    Output Sheet1
    Delete rows with P type: Voip
    Delete values with Type: Cell and Old: Yes
    Output Sheet2
    From the original sheet
    Retain only Type: Cell and Old: Yes
    Then: if column Phone1, type and old has blank records cut and paste from Phone2, type2, old2 and so on to fill in blanks
    Can this be achieve using dictionary Sir?

  • @furzkram
    @furzkram 5 років тому

    The audio level is on the edge of distortion. Remux and take it down by 20% please.

  • @ObeyyShadesz
    @ObeyyShadesz 3 роки тому

    very confusing