Excel VBA Collections: Collections vs Arrays (4/5)

  Рет қаралды 57,561

Excel Macro Mastery

Excel Macro Mastery

Күн бұрын

Пікірлер: 70
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
Thank you for watching this video. If you have any questions, please add a comment below.
@AS-ym2bp
@AS-ym2bp 5 жыл бұрын
This channel is like a gold mine for me. I used to think I knew a lot in VBA but I'm realizing that I'm only scratching the surface. I wonder what other time and memory saving tips are there going forward.
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
Thanks Aashay.
@oziflyer
@oziflyer 4 жыл бұрын
Great series of videos, Paul! One thing that really impresses me is that several times I've thought; "What if i want to...", and within seconds you say "Now you might be thinking... what if I want to...", and say exactly what I'm thinking :-) Oh, and I join the hundreds of other commenters here who say - I've been using VBA for years, and I'm learning new things with every video! Thank you!
@Excelmacromastery
@Excelmacromastery 4 жыл бұрын
Thanks for the feedback. Glad you like the practical advice.
@steveroberts8775
@steveroberts8775 5 жыл бұрын
Thanks Paul another bite size video full of great information and explained very clearly.
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
glad you like it Steve.
@krn14242
@krn14242 5 жыл бұрын
Thanks Paul. Great explanation between Collections and Arrays. Now I understand.
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
that's great to hear😀
@GurgMaster
@GurgMaster 8 ай бұрын
Thanks again - very good stuff again. I'm using it as a refresher but these are some of the best explanations I've seen and I think I'm actually understanding stuff I used to bluff my way through. Cheers
@annaokarmus1334
@annaokarmus1334 4 жыл бұрын
Excel Macro Mystery, good to have you here :) You helped me a lot to understand Arrays & Collections!
@Excelmacromastery
@Excelmacromastery 4 жыл бұрын
Glad it was helpful!
@rickswineberg
@rickswineberg 3 жыл бұрын
Great video, suggest (ctrl + A) also gives current region.
@Excelmacromastery
@Excelmacromastery 3 жыл бұрын
Ctrl + A means select All. It behaves a bit different to Current Region in Excel.
@RicardoCamisa
@RicardoCamisa 4 жыл бұрын
Obrigado pela sua partilha. Gostei muito da forma como esclareceu esta questão. Muito bom...
@wayneedmondson1065
@wayneedmondson1065 5 жыл бұрын
Hi Paul.. great details on using arrays vs. collections. It helps me better understand when to use one vs. the other. Looking forward to more on your channel. Thumbs up!
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
No problem Wayne. Glad that the videos help you understand.
@obsoquasi
@obsoquasi 5 жыл бұрын
The last couple of months I've been working a lot with Tables (as opposed to just Ranges) which are ListObjects in VBA. They handle very similar to Collections and are very intuitive to code with using the "for each" command. Like Collections, it's not the fastest method, but I'd rather not have to deal with having to resize arrays all the time :). And using ListObjects means, all the operations are not just in the memory (as with Collections and arrays), but the result can be seen in the actual table on the Worksheet.
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
I haven't run any speed tests on tables but I think that would be an interesting topic.
@grzegorz2852
@grzegorz2852 2 жыл бұрын
John, you could also put your table into an array and your code will be faster.
@obsoquasi
@obsoquasi 2 жыл бұрын
@@grzegorz2852 For tables where I expect a lot of growth during operation, it's saver for me to access the actual table instead of using an array. It's slower yes, but it's safer and the code is more intuitive to write.
@the_feature_selector859
@the_feature_selector859 4 жыл бұрын
Your videos are easily the most concise Excel VBA videos on the net. Are there many jobs in Ireland that use VBA a great deal?
@jgojiz
@jgojiz 4 жыл бұрын
Very clear and useful, many thanks
@rrrraaaacccc80
@rrrraaaacccc80 7 ай бұрын
Great 💯👍
@CeliaAlvesSolveExcel
@CeliaAlvesSolveExcel 4 жыл бұрын
Great lesson, Paul! Thank you!
@Excelmacromastery
@Excelmacromastery 4 жыл бұрын
You're welcome Celia
@buithitrami175
@buithitrami175 5 жыл бұрын
Hi Paul, thanks for your new video. I have been looking forward to it since your last one 😊
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
Thanks Mi. If you liked it you will like the next one which is one using class modules with collections.
@turkaykoc8587
@turkaykoc8587 Жыл бұрын
Thank you so much
@conan7422
@conan7422 2 жыл бұрын
Updating a single item in a collection is a combination of remove and insert!
@cartoonistgautam1965
@cartoonistgautam1965 4 жыл бұрын
explained in an easiest way i ever came across.
@noviceprogrammer2011
@noviceprogrammer2011 4 жыл бұрын
I never resize an array because it has its limitations and also it's very memory intensive. Instead, since we know the dimensions of the data, any sub array is generally not going to be bigger than the original array, so why not create the sub array to have the same dimensions as the original array, thus removing the need to constantly resize. The only drawback to my method is that the sub array tends to be only partially filled, so you will be creating a big array unnecessarily. To overcome that, you could define a new variable that counts the number of items that matches your criteria, then redim your sub array.
@Vumevume
@Vumevume 5 жыл бұрын
Hi Paul, I see you have several vids on connections. Whenever I have looked at connections I've always preferred to use Dictionaries instead. Wondered what your thought on that might be.
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
Dictionaries are better overall but Collections can be useful on some situations. My next video series is about the VBA Dictionary.
@conan7422
@conan7422 2 жыл бұрын
You should do the redim after next i with redim preserve arr(1 to row-1) Max row is rg.rows.count
@1fredq1
@1fredq1 5 жыл бұрын
Instead of stepping through the rows to decide which ones to add to the array (united states forexample) wouldn't it be faster to do an advanced filter to get what you are after then just add then to the array en masse as shown in the first example?
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
That's true Nigel. AdvancedFilter would be quicker and is better for copying and filtering data in many Excel VBA cases. However, in this video I wanted to compare arrays and collections in very simple terms to really show their differences.
@MrMallesh1
@MrMallesh1 5 жыл бұрын
please share one video on Access Database Connection also..
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
Thanks Mallesh. This is an interesting and useful topic in VBA. I hope to cover it in the future.
@user-pu2zp2ke2l
@user-pu2zp2ke2l Жыл бұрын
Great
@richardgreves6161
@richardgreves6161 4 жыл бұрын
Thanks Paul, this is awesome! I particularly like the ArrayInsert function. I was wondering if it could be adapted for adding formulas rather than strings. I have a sheet that has facility information with a number of variables some of which are formulas) for a given year. When data for the new year becomes available I need to insert a row between the last year of the current facility and the first year of the next facility. Doing this the old way (without arrays) takes forever. With arrays I am not able to get the ArrayInsert function to work unless I store the array as a string which breaks the formula cells.
@bilallechvien4558
@bilallechvien4558 4 жыл бұрын
Cool 👍
@gauravchuarasia5091
@gauravchuarasia5091 Жыл бұрын
You missed that collection can be used for unique list creation while array will read duplicates also in a list
@furzkram
@furzkram 5 жыл бұрын
I would dim the array to the ubound of the region first and then redim the array ONLY ONCE - namely, AFTER all matching rows have been retrieved and only to (row-1) in size. Redim is slowing down the processing and there is no need to adjust the array after each match is found.
@RicardoCamisa
@RicardoCamisa 4 жыл бұрын
Tem como ordenar os dados de uma collection?
@Excelmacromastery
@Excelmacromastery 4 жыл бұрын
You can use this: excelmacromastery.com/excel-vba-collections/#Sorting_a_Collection
@1tempfile1
@1tempfile1 3 жыл бұрын
Hello Mr.Paul Thank You for this great video! And overall great course =) But I have a question about updating values in collection. For example I need to update "orange" to "peach" "orange" have index = 4. I can create function to find index of "orange", store this index in tmpVar, remove this item, add new value before tmpVal. And wrap this code in a function for convenience
@lucasvtiradentes
@lucasvtiradentes 5 жыл бұрын
great video, youre amazing!
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
Thanks Lucas.
4 жыл бұрын
Amazing, thx so much! Yours videos improve my skill and my macros:) Please, i have one question, for my macro i need all files names files in directory. It's possible make collection for files names in directory?
@ghalebevaldo4416
@ghalebevaldo4416 3 жыл бұрын
I ever use a second array to manage such tasks. Thats so fast. Need Not a collection. Not need preserve and redim only once. I write with resize to the sehen. Absolotely fast. But many thankx to explain the difference.
@Excelmacromastery
@Excelmacromastery 3 жыл бұрын
Thanks for sharing!
@niteshprabhu6791
@niteshprabhu6791 5 жыл бұрын
The shortcut keys used in the video are mentioned in the description
@aNDy-qh1em
@aNDy-qh1em 4 жыл бұрын
Hi Paul, do you have somewhere speed comparison in sorting arrays vs collection vs dictionary? Perhaps is there in VBA an open library or module for an analogue of list (incorporating conversion to/from other data structures and methods like sorting)
@johnbill739
@johnbill739 5 жыл бұрын
Hi Paul. Great video. One question. @ 3.50 "Sheet1.Range (F1:I101").value = arr " prints back all the data in the array. I tried doing this in the second array(@ 6:15) when using the "rows" counter but for some reason it gets stuck on the first variable entered into the array. Do I have to loop through to get it to print. Also if you didn't know the range until after the program has completed is there some way of combing "(F1:I101)" to "Rows" to get an exact output range. Thanks again. Video was great
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
The second array is adding one item at a time. This is an array of strings. you can assign it to a range What do you mean my "it gets stuck on the first variable"?
@lucagervini7514
@lucagervini7514 3 жыл бұрын
Hi, and thank you! how is it possible to write the array inside a listobject?
@engrvarsi3774
@engrvarsi3774 4 жыл бұрын
Loved it. I have two questions, and am unable to find answer anywhere... 1: Equivalent of javascript eval() which should work like... eval("msgbox 'show a message'") Here the code is in form of string msgbox "show a message" There is a way in which we take the code window as object, add module and sub programmatically, then execute it but it makes the variables in the current scope simply out of scope and lots of other problems. 2: How may I increase or decrease the number of dimensions of an Array... is that possible?
@naumansarwar8216
@naumansarwar8216 4 жыл бұрын
Thanks for the tutorial. I have a question. I tried the collection method which was very helpful and I thought to make a function with it as currently, I am using a long array normal formula without VBA which is lengthy and makes the sheet heavy. but when I tried to make a function which is exactly from the same example above it working from a second macro and give the correct answer but when I apply it on a sheet it gives #value error. can you please guide.
@tonyfreelance4519
@tonyfreelance4519 5 жыл бұрын
Hello, Just found your site and really like the ideas, very different to my current approach and can see how I could use many of these techniques. I was wondering if there is a way to download a copy of the example sheets you are showing us on each of your videos. If I missed something please help me find it and if I have to buy or signup please let me know what to do. Thank You Tony :-)
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
Hi Tony. The worksheets for the videos aren't available. However I cover many of these topics in my live webinars which are free. The replays and code are available to website members here excelmacromastery.com/live-webinars/
@akashtribhuvan9227
@akashtribhuvan9227 3 жыл бұрын
will Collections or Arrays accept formula error values?
@rrrprogram4704
@rrrprogram4704 4 жыл бұрын
One question... If our need is to only filter the rows and paste it ... then, isn't POWER QUERY is the most efficient and easiest way ???
@Excelmacromastery
@Excelmacromastery 4 жыл бұрын
Power Query is certainly a great tool. But whether it is best depends on the requirements. My examples are very simple and certainly Power Query can do the job for these but with a more complex scenario it may be different.
@binlee3866
@binlee3866 3 жыл бұрын
SQL Query with Ado is also efficient.
@H2Dwoat
@H2Dwoat 4 жыл бұрын
Hi, when using currentregion does it include cells hidden by a filter?
@mrashid229
@mrashid229 3 жыл бұрын
Yes it does! Life would have been easier if that wasn't the case, when you would try to copy (to array) rows based on some criteria[s].
@TravisFX
@TravisFX 3 жыл бұрын
Hmm. how about read a list into an array, then pump that into a collection?
@MrMallesh1
@MrMallesh1 5 жыл бұрын
nice video , plz share on udemy also. Thanks
@Excelmacromastery
@Excelmacromastery 5 жыл бұрын
why on Udemy?
Excel VBA: Using Class Modules with Collections (5/5)
13:37
Excel Macro Mastery
Рет қаралды 70 М.
Watch these 28 minutes if you want to become an Advanced VBA user...
29:01
Excel Macro Mastery
Рет қаралды 53 М.
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 14 МЛН
Touching Act of Kindness Brings Hope to the Homeless #shorts
00:18
Fabiosa Best Lifehacks
Рет қаралды 19 МЛН
Фейковый воришка 😂
00:51
КАРЕНА МАКАРЕНА
Рет қаралды 7 МЛН
Как мы играем в игры 😂
00:20
МЯТНАЯ ФАНТА
Рет қаралды 1,3 МЛН
10 Years of VBA Array Knowledge in 40 Mins
41:57
Excel Macro Mastery
Рет қаралды 19 М.
5 More things I wish I Knew When I Started Using Excel VBA
13:31
Excel Macro Mastery
Рет қаралды 71 М.
Free Excel VBA Course #26 - Using Arrays in VBA
47:33
TrumpExcel
Рет қаралды 40 М.
How To Master Arrays In Excel VBA + FREE MACROS & CHEAT SHEET
29:09
Excel For Freelancers
Рет қаралды 8 М.
How to Use Arrays Instead of Ranges in Excel VBA
10:20
Excel Macro Mastery
Рет қаралды 200 М.
Which is the Fastest VBA Method For Reading Tables?
8:39
Excel Macro Mastery
Рет қаралды 42 М.
How to get the Last Row in VBA(The Right Way!)
15:41
Excel Macro Mastery
Рет қаралды 159 М.
Excel LAMBDA - HOW & WHEN you Should use it
16:02
Leila Gharani
Рет қаралды 438 М.
VBA For Loop Data Matching using Array
17:29
Coding Module
Рет қаралды 15 М.
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 14 МЛН